Closed StarMonk closed 1 year ago
https://github.com/uNetworking/uWebSockets.js/discussions/843
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');
I didn't realize, it was that simple.
Thanks
I am trying to store unique
ws
for each connected client so that I can re-use it to send messages to the connected client.How
isSubscribed
handles and stores each connection string?