Socket io provides additional features over a plain websocket object which are listed below.
Socket io rooms limit.
In disconnect event you can query this object to know the rooms you have to leave.
Additonally if rooms list is temporary you can clean it whit controlled event after disconnecting.
My question is how can this be handled on the client side.
A socket belongs to a certain namespace by default and uses an underlying client to communicate.
Socket io is not a websocket implementation.
Push data to clients that gets represented as real time counters charts or logs.
In that case every socket in the room excluding the sender will get the event.
What socket io is not.
Rooms are used to further separa.
If you are using some db o nosql you can save it for distributed environments.
Any of the above examples specific to versions mentioned above you are querying the rooms property on socket io redis adapter.
Where you can save socket id or other identifier with rooms.
These channels are called rooms.
When a user connects they automatically join the room that i have setup.
It provides a socket io middleware to deal with wildcards.
Within each namespace you can also define arbitrary channels called room that.
Not in socket io directly but check out this plugin by hao kang den.
I have a problem regarding the handling of multiple chat rooms.
Although socket io indeed uses websocket as a transport when possible it adds additional metadata to each packet.
Can i use wildcards in events.
Socket io rooms within each namespace you can also define arbitrary channels that sockets can join and leave.
But first let s detail what the socket io library is not.
However the problems is that the connection is persistent and i wish to address the problem by using the socket leave room method.
Socket io enables real time bidirectional and event based communication.
It works on every platform browser or device focusing equally on reliability and speed.
Prevent flooding from single connection.
Limit number of events by ip uniqueuserid or and socket id with rate limiter.
A socket is the fundamental class for interacting with browser clients.
To leave a channel you call leave in the same fashion as join both methods are asynchronous and accept a callback argument.