3

I have a socket configured with Ratchet to listen to messages in the client like this:

var sock = new WebSocket("ws://localhost:2000");
sock.onmessage = new function(evt){
  //Listen to redis subscribe
}
sock.onopen .. 
sock.onclose ..

I am trying to connect to a redis pubsub channel and listen to the messages. I know how to subscribe to a redis channel in php but I am trying to figure out how to configure Ratchet's onMessage to listen to redis' subscribe. Is it possible to modify Ratchet to listen to redis subscribe on a certain channel? Are there any documentation I could read up on? Could not find much information online. Any advice is appreciated.

Pavel
  • 31
  • 1
  • 2
  • I am not familiar with "redis pub/sub" but if it is event based and you can attach a function to that event you can call a method on your ratchet class to send data to users connected to the socket – MarshallOfSound Jul 19 '15 at 22:05

1 Answers1

0

There's an asynchronous redis client build over react which allows you to assign callbacks to redis pubsub in non-blocking way. Works perfectly with ratchet.

Take a close look at their github: predis/async.

Eugene Sue
  • 1,320
  • 1
  • 9
  • 13