node.js socket.io cannot send to specific client

后端 未结 1 1187
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-23 15:13

I found a few references to this but nothing that actually direct helps. Also according to some research this is the proper way to send a message to a specific client. I have:

1条回答
  •  走了就别回头了
    2021-01-23 15:53

    For socket.io 1.0 use:

    io.sockets.connected[players[i].id].emit('deal_card', {..});
    

    For 0.9 use:

    io.sockets.sockets[players[i].id].emit('deal_card', {..});
    

    (not io.sockets.socket[players[i].id].emit('deal_card', {..});)

    0 讨论(0)
提交回复
热议问题