I am trying to use socket.io to broadcast only to users of a specific room (in another word, to send to all users in that room except me, the sender). So far, I have tried:
JavaScript
x
5
1
io.of("/").in(room_temp).broadcast.emit('transcription', data);
2
io.of("/").to(room_temp).broadcast.emit('transcription', data);
3
io.of("/").broadcast.in(room_temp).emit('transcription', data);
4
io.of("/").broadcast.to(room_temp).emit('transcription', data);
5
None of them work unfortunately.
Advertisement
Answer
io.of("/").to(room_temp).emit('transcription', data);
would submit to everyone in the room include the user itself.
socket.to(room_temp).emit('transcription', data);
would submit to everyone in the room except yourself.