Replies: 1 comment 1 reply
-
const wsMap = new Map();
subscriber.subscribe('message', (data) => {
data = JSON.parse(data);
const ws = wsMap.get(data.sender);
(ws || app).publish(data.topic, data.message);
});
app.ws('/', {
open: (ws) => {
wsMap.set(ws.id, ws);
},
close: (ws) => {
wsMap.delete(ws.id);
}
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all,
awesome application, thank you for your work. I have a problem that looks like i cant figure it out by myself, so i want ask here for help.
I want to build up my Server code with scaling in mind from the ground up, so i don't have the hassle later. For this, i used the famous Redis pub/sub mechanics. I want to send a message to all clients, except to the client where the message comes from, because he has the data already locally. Here a little bit of code to demonstrate my problem (stripped down to the problem):
( I have read a few other discussions about this, but could not find a answer to this problem )
The functionality that i need has ws.publish, but i cannot access it at the location where i need it, or is there a way? Did i think wrong? Can someone point me in the right direction and help me in this situation?
I can give more information's if needed.
Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions