Listen to PHP Events from other script
Would there be a way to use PHP to send an event to the server, which will emit the message to the clients?
I could be something like this:
$i = 0; while($i <= 1000){ echo $i."\n"; $i++; $messageEvent = new Event\MessageEvent(); $messageEvent->setMessage(array( 'event' => 'addme', 'message' => "Count $i", )); $messageEvent->setEndpoint(null); $dispatcher = Event\EventDispatcher::getDispatcher(); $dispatcher->dispatch("server.addme", $messageEvent, null); sleep(1); }
I wish to build an application that reacts on events in PHP and pushes these through socketio. I think the best way would be to integrate this in the server, instead of having a client that'll post it to the server, who will need to handle the events.
There's no php socketio client side implements. But you can send a event over websocket or simple HTTP POST.
Here is the socketio protocol spec.
https://github.com/socketio/socket.io-protocol