So to clarify, I know the client should send a message such as 'join-room' to the server for handling, and thats fine, and I know I can do the same for 'leave-room'.
What I want is to actually listen to the events themself, because say if a client disconnects, I need to send a message to the rooms affected, as when a client disconnects then they automatically leave all rooms.
So I want something like;
socket.on('join' function() {
// send message
});
socket.on('leave' function() {
// send message
});
So that if the user closes the window (which disconnects the client, and then triggers all the rooms to be left) I can send a message out.
I am using the latest socket.io, with the redis adaptor.
Also;
What is the most efficient way to list all the rooms a particular socket is in, as technically I think the disconnect event should contain the client_id so I could do this manually.
The key thing is clarity and stability, although I am open to alternate approaches (must still use socket.io).
Thanks
Aucun commentaire:
Enregistrer un commentaire