Skip to content
Discussion options

You must be logged in to vote
let id = 0;
const wsMap = new Map();

app.ws('/', {
   open: ws => {
      ws.id = ++id;
      wsMap.set(id, ws);
      console.log('open', ws.id);
   },
   close: (ws, code) => {
      wsMap.delete(ws.id);
      console.log('close', ws.id, code);
   }  
});

wsMap.get(id).send('Hello');

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@StarMonk
Comment options

@StarMonk
Comment options

@StarMonk
Comment options

@e3dio
Comment options

@StarMonk
Comment options

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