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..
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Netty websocket client does not read new frames fr
- google-drive can't get push notifications
- How to reimport module with ES6 import
- Why is `node.js` dying when called from inside pyt
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);