0
votes

my app is separated to mutltiple apps (admin, client, worker).

I'm using socket.io with RedisStore, when an admin logs in I set a socket.io connection and join the socket to a room named user_id

how can I broadcast to this room from a different app (let's say from the worker) without creating a server for socket.io to listen to ?

io.set (to set the RedisStore) is defined for var io = require('socket.io').listen(server)

do I need to publish directly to the redis channel ? if so, how do I know it's name ?

1

1 Answers

0
votes

One way to have multiple Node instances communicate via messages would be using a message broker (message queue service). Each Node instance binds to a specific channel in the MQ, such as "general_chat", or "maintenance". All the instances would then receive those messages. You may event add multiple binding levels with dot syntax "chat.room1" and "chat.admin". Check out ActiveMQ, RabbitMQ, SQS and other similar services, some are open-source.