Closed Florry closed 7 years ago
Adds web sockets (aka fruster web bus) to api gateway.
To send a message to a client, simply send a request to ws.:userId.>.
ws.:userId.>
Example: sending to ws.79f76857-e103-4fed-9190-62d19eb1c1bb.new-message (for a specific user) or sending to ws.*.new-message (for all connected user):
ws.79f76857-e103-4fed-9190-62d19eb1c1bb.new-message
ws.*.new-message
{ "redId":"4d608585-23c8-469a-9d66-16289ffaf88a", "data":{ "totalMessageCount": 32, "newMessages": 1 }, "transactionId": "2162c0d8-aa8f-41a9-937c-7d9a14b545b9" }
Client connects to ws://localhost:3000 using the fruster web bus client (See https://github.com/FrostDigital/fruster-web-bus-client);
ws://localhost:3000
var bus = new FrusterWebBusClient("ws://localhost:3000"); bus.subscribe(`ws.${userService.userId}.new-message`, (msg) => { messageService.totalMessageCount = msg.data.totalMessageCount; messageService.newMessags += msg.data.newMessages; }); bus.subscribe("ws.${userService.id}.friend-service.new-friend-request", (msg) => { console.log(msg.data.message); }); bus.onError(err => { console.error("ERROR", err); }); bus.onClose(closeEvent => { console.error("CLOSED", closeEvent); });
retest this please
Adds web sockets (aka fruster web bus) to api gateway.
To send a message to a client, simply send a request to
ws.:userId.>
.Example: sending to
ws.79f76857-e103-4fed-9190-62d19eb1c1bb.new-message
(for a specific user) or sending tows.*.new-message
(for all connected user):Client connects to
ws://localhost:3000
using the fruster web bus client (See https://github.com/FrostDigital/fruster-web-bus-client);