-
-
Save hervehobbes/915885917ab25e4131e7 to your computer and use it in GitHub Desktop.
Ratchet and Predis-async. (React and Redis).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use RatchetApp\Pusher; | |
| require __DIR__ . '/../vendor/autoload.php'; | |
| $loop = React\EventLoop\Factory::create(); | |
| $pusher = new Pusher(); | |
| $loop->addPeriodicTimer(10, array($pusher, 'timedCallback')); | |
| $client = new Predis\Async\Client('tcp://127.0.0.1:6379', $loop); | |
| $client->connect(array($pusher, 'init')); | |
| // Set up our WebSocket server for clients wanting real-time updates | |
| $webSock = new React\Socket\Server($loop); | |
| $webSock->listen(8080, '0.0.0.0'); | |
| $webServer = new Ratchet\Server\IoServer( | |
| new Ratchet\WebSocket\WsServer( | |
| new Ratchet\Wamp\WampServer( | |
| $pusher | |
| ) | |
| ), | |
| $webSock | |
| ); | |
| echo "Pusher starting...\n"; | |
| $loop->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment