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.
Socket io private room.
Now that we are well acquainted with socket io let us write a chat application which we can use to chat on different chat rooms.
We will allow users to choose a username and allow them to chat using them.
Socket io provides a dynamic list of the rooms that each socket is a member of.
We can retrieve this list and use it as needed.
3 private messaging a chat app with socket io and reactjs duration.
Build real time chat rooms with node js and socket io duration.
Rooms also share the same socket connection like namespaces.
Leon watson 13 348 views.
The list will be dynamically updated if the socket leaves any of its rooms.
To leave a channel you call leave in the same fashion as join both methods are asynchronous and accept a callback argument.
In that case every socket in the room excluding the sender will get the event.
In this recipe we will create a list of the rooms that our socket is in.
Rooms are used to further separate concerns.
One thing to keep in mind while using rooms is.
These channels are called rooms.