Using Redis to communicate between PHP and socket.io/node.js -
i have php app built , running on apache, using nginx reverse proxy serve static resources.
i have redis installed using store activity id's each users activity stream. activity gets written mysql database, redis pushes activity id each users stream. when user receives his/her activity stream, app first retrieves users list of activity id's redis , gets actual activity data via mysql in() query.
this works well, want start add real time capability set up. able push these events straight users browser , add general live notifications.
for have installed node.js socket.io. have socket.io server correctly , running , client automatically connected on page load.
where struggling in understanding how post message socket.io within php app. since php , node.js cannot communicate directly, understanding best off utilizing redis go-between since have installed , , running. have no idea how go this.
what need description of process (any code examples helpful) of sending notification php redis , socket.io in order pushed relevant client.
also, not understand how socket.io know client send to. how pass information along , keep synced? necessary? need store php sessions in redis , have socket.io collect data when user connects? or there way?
thanks in advance.
please note: php session data saved disk.
you can set pubsub channel on redis (please see http://redis.io/topics/pubsub). subscribe node.js process. php publish pubsub communicate node. can have separate pubsub channels different clients , publish whatever channels need reach specific clients.
Comments
Post a Comment