Skip to content

app.publish exclude sender in redis sub #732

Answered by e3dio
ghost asked this question in Q&A
Discussion options

You must be logged in to vote
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);
   }
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ghost
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant