Leon watson 13 348 views.
Socket io private room.
The list will be dynamically updated if the socket leaves any of its rooms.
3 private messaging a chat app with socket io and reactjs duration.
Rooms also share the same socket connection like namespaces.
So first let us set up our html file to request for a username var app require.
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.
These channels are called rooms.
Allows for private rooms where a key is used and storing data for a room.
Socket io provides a dynamic list of the rooms that each socket is a member of.
In that case every socket in the room excluding the sender will get the event.
One thing to keep in mind while using rooms is.
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.
Rooms are used to further separate concerns.
In this recipe we will create a list of the rooms that our socket is in.
We will allow users to choose a username and allow them to chat using them.
Within each namespace you can also define arbitrary channels that sockets can join and leave.