What's the difference between io.sockets.emit and broadcast?

后端 未结 3 1597
逝去的感伤
逝去的感伤 2020-11-29 18:25

What\'s the difference between io.sockets.emit and socket.broadcast.emit? Is it only that broadcast emits to everyone BUT the socket that sends it?

It seems like the

3条回答
  •  离开以前
    2020-11-29 18:36

    socket.broadcast.emit() behaves similar to io.sockets.emit, but instead of emitting to all connected sockets it will emit to all connected socket except the one it is being called on. So in this case the socket referenced by socket will not receive the event.

提交回复
热议问题