How can I trigger events to fire on connected clients using node.js, sockets.io and redis?
Ok, so I previously asked a question asking about my options, I have looked into sockets.io and Redis, and really like what I see.
Anyway, I would like to have multiple clients connected to a node.js server. Then when my redis db has a change, for example some boolean from 0 to 1, I want all node.js connections to send this update to all clients.
I am not looking for some Code to loop and check for this change, I am wondering how I can fire an event to specific clients when a change is made in a redis db. Any psuedo code to help me get my mind around this, would be awesome. I would also really appreciate any node.js code that shows how to hook an event to changes in a redis instance.
I can't write any node.js code for you, but sounds like what you want is exactly what Redis's pub/sub functionality is for:
Each node.js client would subscribe to a channel, where they will block/wait for messages to arrive. No looping/polling required.