Is there a way to clear every room? #3988
-
Is there a way I can remove every socket from every room, effectively deleting all rooms that aren't socket client rooms? |
Beta Was this translation helpful? Give feedback.
Answered by
darrachequesne
Jun 24, 2021
Replies: 1 comment
-
Hi! There is no built-in way, but you should be able to do it manually: for (const [_, socket] of io.of("/").sockets) {
for (const room of socket.rooms) {
if (room !== socket.id) {
socket.leave(room);
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
darrachequesne
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! There is no built-in way, but you should be able to do it manually: