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..
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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);