sharing IO object in multiple node instances

后端 未结 2 652
一个人的身影
一个人的身影 2021-01-25 02:55

I want to share rooms created by socket.io between two node instances, already using redis-store but unable to get io.sockets.in(ROOM_ID).emit(MESSAGE,DATA) on different node in

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-25 03:31

    Answering to the queries related to the questions - one,two and this one.

    Exact point where I need to concentrte was - Joinig the room.

    I was using client_socket.join("room_name"), but it pushes the client socket to the room.

    Now, try io.sockets.socket(client_socket.id).join("room_name").

    This pushes the room members to the redis and now they are accessible in another node instance.

    in process B io.sockets.in("room_name").emit("event_name",{data:"1"}) works.

提交回复
热议问题