I want to statically remove all users from a room, effectively deleting that room. The idea is that another room with the same name may be created again in the future, but I want it created empty (without the listeners from the previous room).
I'm not interested in managing the room status myself but rather curious as if I can leverage socket.io internals to do this. Is this possible? (see also this question)
From the client, you send your own message to the server and ask the server to remove it from the room. The server can then use socket. leave("someRoom") to remove that socket from a given room. Clients cannot join or leave rooms themselves.
socket.io rooms are a lightweight data structure. They are simply an array of connections that are associated with that room. You can have as many as you want (within normal memory usage limits). There is no heavyweight thing that makes a room expensive in terms of resources.
Once you reboot your machine, you will now be able to happily go to 55k concurrent connections (per incoming IP).
Also, it's worth mentioning that...
Upon disconnection, sockets leave all the channels they were part of automatically, and no special teardown is needed on your part.
https://socket.io/docs/rooms-and-namespaces/ (Disconnection)
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