Replies: 1 comment 5 replies
-
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'); |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
StarMonk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to store data received from websocket to REDIS and maintain ws relationship between the user and WebSocket id
But the only option, I see is:
getRemoteAddressAsText
, but this option is unreliable, since multiple users can have the same address.ws
returnsuWS.WebSocket {}
and I looked into the WebSocket interface, but I can't find any unique Identifier.Beta Was this translation helpful? Give feedback.
All reactions