Send response to all clients except sender

前端 未结 10 1638
囚心锁ツ
囚心锁ツ 2020-11-22 14:26

To send something to all clients, you use:

io.sockets.emit(\'response\', data);

To receive from clients, you use:

socket.on         


        
10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 15:20

    use this coding

    io.sockets.on('connection', function (socket) {
    
        socket.on('mousemove', function (data) {
    
            socket.broadcast.emit('moving', data);
        });
    

    this socket.broadcast.emit() will emit everthing in the function except to the server which is emitting

提交回复
热议问题