Sending to all in room, including self
See original GitHub issueI cannot seem to find a way how to emit event to all clients inside a room including self.
Basicly socket.in('myroom').broadcast.emit()
emits to all, except self and socket.in('myroom').emit()
sends only to self.
I know I can do both at the same time, but that doesn’t feel effective to me.
How do I emit to all clients in the room, including self with one call?
Update:
Okay, I manged to emit to all with io.sockets.in('myroom').emit();
, but that made me introduce io
into global scope, that kind of ruins my decoupling.
Is there a way to do it through socket
object?
Issue Analytics
- State:
- Created 11 years ago
- Comments:9
Top Results From Across the Web
javascript - Socket.Io how to emit to all members in a room ...
Send to both room and self. As a work-around, you could also just send to both: socket.broadcast(room).emit(...); socket.emit(...); ...
Read more >Emit cheatsheet - Socket.IO
WARNING: `socket.to(socket.id).emit()` will NOT work, as it will send to everyone in the room // named `socket.id` but the sender.
Read more >Socket.IO - Broadcasting - Tutorialspoint
Broadcasting can be done at multiple levels. We can send the message to all the connected clients, to clients on a namespace and...
Read more >Broadcasting event to all clients including sender - Laracasts
What happens is that when i broadcast a laravel event all clients get updated except the sender but when sending other events from...
Read more >Managing breakout rooms - Zoom Support
* While both the host and any co-hosts have the ability to assign participants to breakout rooms, only the first submitted set of...
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 FreeTop 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
Top GitHub Comments
FWIW in v1.0 you can do
socket.nsp.to(room).emit(event);
@yads Works well, thanks