sharing IO object in multiple node instances

后端 未结 2 692
一个人的身影
一个人的身影 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:50

    If i good understanding your problem. youre start point was this question You can probably access to A from B (host not redis). So in A you can push that's you need to emit on A:

    LPUSH dataToEmit "{'room':'room-ABCD', 'data':''}" 
    

    and on your A process you perform a BRPOP on dataToEmit and on the callback you can unjsonize and emit that you want

    may be you could also dispatch to 1 key for 1 room . Don't forget that's you can use a specific data base number for this stuff

    I Hope that's migth help you

提交回复
热议问题