Created
January 22, 2013 12:09
-
-
Save jmoz/4594162 to your computer and use it in GitHub Desktop.
Ratchet and Predis-async. (React and Redis).
This file contains 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