Example #1
0
<?php

use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use CoffeeTrack\Application;
use Ratchet\WebSocket\WsServer;
use React\ZMQ\Context;
require __DIR__ . '/vendor/autoload.php';
$application = new Application();
$server = IoServer::factory(new HttpServer(new WsServer($application)), 7777);
$context = new Context($server->loop);
$pull = $context->getSocket(\ZMQ::SOCKET_PULL);
$pull->bind('tcp://127.0.0.1:4444');
$pull->on('message', function ($data) use($application) {
    $application->onIncomingZMQ($data);
});
$server->run();