I have some code where a socket is made to join multiple rooms. At some point in the code, i want to leave all the rooms at one go, without disconnecting the socket. Is it possible to do this? If yes, then how can i do this? Thanks in advance..
I am using socket.IO
In the first case, the Socket will automatically try to reconnect, after a given delay.
You can check the socket. connected property: var socket = io. connect(); console.
That's possible. You can leave rooms without disconnecting the socket. The socket disconnects only when you make a call to socket.disconnect().
To do this you'll have to maintain a list of rooms each client joins and leaves. To leave all rooms iterate through this list and make a call to socket.leave(roomname);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With