Socket io already keeps a copy of this list.
Socket io rooms list.
I m not sure where i m going wrong.
For your convenience each socket automatically joins a room identified by its id see socket id.
During development socket io serves the client automatically for us as we ll see so for now we only have to install one module.
After progress on the question how to create socket io multicast groups i found making rooms a great way to do what i needed.
I m trying to get a list of created rooms in an application by using io sockets adapter rooms.
In that case every socket in the room excluding the sender will get the event.
Each socket in socket io is identified by a random unguessable unique identifier socket id for your convenience each socket automatically joins a room identified by its own id.
I m just getting strings of socket id s and not their names.
A client library that loads on the browser side socket io client.
I m trying to get a list of all the sockets clients that are currently connected.
However it would be great to know about all the rooms without an ex.
One thing to keep in mind while using rooms is.
A server that integrates with or mounts on the node js http server socket io.
Were either incorrect or incomplete if you use 2 0.
The mechanics of joining rooms are handled by the adapter that has been configured see server adapter above defaulting to socket io adapter.
All the answers above and the one here socket io get rooms which socket is currently in or here socket io how do i get a list of connected sockets clients.
Rooms are used to further separate concerns.
Rooms also share the same socket connection like namespaces.
To leave a channel you call leave in the same fashion as join both methods are asynchronous and accept a callback argument.
In 2 0 io sockets manager and io sockets clients don t exist anymore.
Without using namespace the following 3 parameters can all get sockets in a specific room.
If you are using some db o nosql you can save it for distributed environments.
In disconnect event you can query this object to know the rooms you have to leave.
Socket io is composed of two parts.
Io sockets does not return an array unfortunately.
Here s a snippet of my code.
Where you can save socket id or other identifier with rooms.
Additonally if rooms list is temporary you can clean it whit controlled event after disconnecting.