How to leave all rooms the socket is currently in and join only one room? #4905
Unanswered
cedrick-ah
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi! To leave all rooms: socket.rooms.forEach(room => {
if (room !== socket.id) {
socket.leave(room);
}
}); Could you please provide some code reproducing the issue? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using socket.io version 4.5.1, nodejs version 16
I'm trying to leave all rooms and subscribe to a new one, but I'm still receiving old events, I checked the content of io.of("/").adapter.rooms and when the socket join its added under the room but but when the socket leave the socket is not removed from the room.
Beta Was this translation helpful? Give feedback.
All reactions