Warm tip: This article is reproduced from serverfault.com, please click

socket.io broadcast in a room

发布于 2020-11-28 22:09:24

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:

io.of("/").in(room_temp).broadcast.emit('transcription', data);
io.of("/").to(room_temp).broadcast.emit('transcription', data);
io.of("/").broadcast.in(room_temp).emit('transcription', data);
io.of("/").broadcast.to(room_temp).emit('transcription', data);

None of them work unfortunately.

Questioner
gshow8 shac
Viewed
0
gshow8 shac 2020-12-02 23:03:55

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.