Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to delete a room in socket.io

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)

like image 572
Renaud Avatar asked Apr 28 '14 13:04

Renaud


People also ask

How do you remove a socket from a room?

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.

How many rooms can Socket.IO have?

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.

How many players can Socket.IO handle?

Once you reboot your machine, you will now be able to happily go to 55k concurrent connections (per incoming IP).


1 Answers

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)

like image 126
Jakub Duchon Avatar answered Sep 17 '22 07:09

Jakub Duchon