I want the server to send a message to all room clients when one of them disconnects.
Something like this:
socket.on('disconnect', function() {
server.sockets.in(room).emit('bye');
});
But…
- How do I know which room to broadcast?
- What if the client has joined to multiple rooms?
After inspecting the sockets object, I came up with this solution: