0
All clients are receiving the message via socket.io.
I would like only users who are in the room receive.
Server.js
sockets.on('connection', function (action) {
action.join('testroom');
action.on('say to someone', function(msg){
sockets.to('testroom').emit('some event', msg);
});
});
Client in which the message is sent:
Client A
socket.on('connect', function () {
socket.emit('join', 'testroom');
});
socket.on('some event', function (data) {
console.log(data);
});
$('form').submit(function () {
event.preventDefault();
socket.emit('say to someone', $('#m').val() );
$('#m').val('');
});
Client who is receiving the message improperly:
Client B
socket.on('connect',(socket) => {
socket.on('some event', data => {
console.log(data);
});
});
Ps: Client B is being used in Vuejs.