1
How do I send a message to a specific room? guy:
server.js
io.in('roomA').on('msg', function(msg) {
...
});
client js.
io.in('roomA').emit('msg, 'Hi');
1
How do I send a message to a specific room? guy:
server.js
io.in('roomA').on('msg', function(msg) {
...
});
client js.
io.in('roomA').emit('msg, 'Hi');
2
According to the official documentation, to send a message to a specific room you can use the example below:
//enviando para todos na sala (room) 'game', com exceção do remetente
socket.to('game').emit('nice game', "let's play a game");
// enviando para todos na sala (room) 'game', incluindo o remetente
io.in('game').emit('big-announcement', 'the game will start soon');
Browser other questions tagged javascript node.js socket.io
You are not signed in. Login or sign up in order to post.