Ratchet PHP - Push Messaging Service
Most of the examples I'm looking at with Ratchet are for chat services, and I'm currently building an application where the user logs in and receives notifications from the server
Solution 1:
The $conn
parameter is a implementation of the ConnectionInterface - it has a send()
method. So that's how you can send messages to the client.
Ratchet (via React.PHP) also supports timers. So if there's no external dependency, you can just use $loop->addPeriodicTimer()
to send messages to every client every 60 seconds.
If you need to send messages based on some external dependencies (like a web server request or a cron script), use ZMQ (Ratchet docs). It's easy.
Check out my slides about WebSockets in PHP. The notes are in Czech, but you can find the source code examples useful.
Post a Comment for "Ratchet PHP - Push Messaging Service"