Wednesday, 31 May 2017

The server is sending the message to all users. Why not only to the specific room?

The server is sending the message to all users. Why not only to the specific room?

Server

sockets.on('connection', function (socket) {
    var room = 'room';
    socket.join(room);  

    socket.on('say to someone', msg =>{
        socket.broadcast.to(room).emit('some event',msg);
        socket.in(room).emit('some event',msg);
        socket.to(room).emit('some event',msg);
    });
});



via Eduardo Bennertz

No comments:

Post a Comment