jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [socket.run.php] - Rev 2

Compare with Previous - Blame - Download


<?php

/**
 * @author Jakub PetrŞílka <petrzilka@czweb.net>
 */
require_once('init.php');

use Phem\Core\Collection;
use Phem\Environment\Application;
use Phem\Libraries\MessageBus\MessageBus;
use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;
use React\EventLoop\Factory;
use React\Socket\Server;

$loop = Factory::create();

$msgBus = new MessageBus();

// Listen for the application notifications
$pullerClassName = ROOT_NAMESPACE."\\Libraries\\MessageBus\\"
        . WEBSOCKET_PULLER_MODE."Puller";
if (class_exists($pullerClassName))
{  
    $puller = new $pullerClassName($loop,$msgBus);
    $puller->listen(WEBSOCKET_PULLER_BIND_ADDR,WEBSOCKET_PULLER_PORT);
}
else if (strtolower(WEBSOCKET_PULLER_MODE) != "disabled")
{
    throw new Exception("Unsupported mode given by WEBSOCKET_PULLER_MODE");
}

// Listen for the websocket connections
$webSock = new Server($loop);
$webSock->listen(WEBSOCKET_PORT, WEBSOCKET_BIND_ADDR);
$server = new IoServer(new HttpServer(new WsServer($msgBus)), $webSock);

// Clear previous application scope user cache
Application::setUsers(new Collection());

$loop->run();

Powered by WebSVN 2.2.1