Sending a message to multiple rooms
See original GitHub issueIs it possible to send (emit) a message to multiple rooms in such a way that if a client is a member of two rooms then he gets the message only once?
In the Socket.IO Node.js server this can be done as follows:
io.to('room1').to('room2').to('room3').emit('some event');
However socketio.emit
seems to accept only one room
as argument.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Sending messages to multiple rooms using Socket.io?
Yes, it's possible to emit to multiple rooms altogether. From the tests: socket.on('emit', function(room){ ...
Read more >Post a message to multiple channels - Microsoft Support
In a channel, select New conversation > Format. ; Choose the message type you want: New conversation or Announcement. ; Select Post in...
Read more >Rooms | Socket.IO
A room is an arbitrary channel that sockets can join and leave. It can be used to broadcast events to a subset of...
Read more >XEP-0045: Multi-User Chat - XMPP
Messages sent within multi-user chat rooms are of a special type "groupchat" and are addressed to the room itself (room@service), then reflected to...
Read more >Sharing screen and broadcasting to breakout rooms
Click Broadcast, and select Broadcast Message. Enter your message and click the send icon . The message will appear for all participants in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this feature would be useful, and moreover it would be coherent with the Node.js implementation.
In fact I would like to propose the following implementation for the case when the client list is stored in an in-memory structure:
Then the SocketIO server can be started via
or (in the case of
flask_socketio
)Once this is done, a message can be sent to multiple rooms as follows:
Of course, this is limited to the case when the client list is stored in an in-memory structure.
Right, unfortunately I cannot do it this way because it introduces a difference in how single and multiple servers are implemented. When I look at this I’ll have to find a solution that also works for multi-server deployments.