One thing to keep in mind while using rooms is.
Socket io private room.
We will allow users to choose a username and allow them to chat using them.
To leave a channel you call leave in the same fashion as join both methods are asynchronous and accept a callback argument.
We can retrieve this list and use it as needed.
Within each namespace you can also define arbitrary channels that sockets can join and leave.
These channels are called rooms.
Socket io provides a dynamic list of the rooms that each socket is a member of.
Leon watson 13 348 views.
3 private messaging a chat app with socket io and reactjs duration.
In that case every socket in the room excluding the sender will get the event.
The list will be dynamically updated if the socket leaves any of its rooms.
Allows for private rooms where a key is used and storing data for a room.
Build real time chat rooms with node js and socket io duration.
So first let us set up our html file to request for a username var app require.
Rooms are used to further separate concerns.
Rooms also share the same socket connection like namespaces.