All clients are receiving the message through socket.io. I wish only the users in the room would 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 on which you send the message:
Client
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('');
});
Customer who is receiving the message wrongly:
Client
socket.on('connect',(socket) => {
socket.on('some event', data => {
console.log(data);
});
});
Ps: Client B is being used in VueJs.