Skip to content
Discussion options

You must be logged in to vote

how can I access ws in get request

let id = 0;
const wsMap = new Map();

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

app.get('/', res => {
   const ws = wsMap.get(id);
   ws.publish(msg);
});

Replies: 1 comment 1 reply

Comment options

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

Answer selected by igneous8k
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