Sending message to specific client with socket.io and empty message queue

后端 未结 9 2052
误落风尘
误落风尘 2020-12-22 20:16

I´m going crazy with socket.io! Documentation is so bad it\'s simply not true.

I want to send a feedback to specific client over socket.io

My server side loo

9条回答
  •  忘掉有多难
    2020-12-22 20:57

    In socket.io 1.0, this is how it would work. It may work for lower versions, but I cannot guarantee it.

    socket.to(socket_id_here).emit('new', 'hello');
    

    This works because socket.io automatically adds a socket to a room with the socket's id on connection.

    Also, if you plan to upgrade to version 1.0, there are a lot of changes to the api, so you'll sometimes have to change some code to make it work in 1.0.

提交回复
热议问题