jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Libraries/] [MessageBus/] [ReactSocketPuller.php] - Rev 2

Compare with Previous - Blame - Download


<?php

namespace Phem\Libraries\MessageBus;

use React\EventLoop\LoopInterface;
use React\Socket\ConnectionInterface;
use React\Socket\Server;

/**
 * @author Jakub PetrŞílka <petrzilka@czweb.net>
 */
class ReactSocketPuller extends WebsocketPuller
{

    protected $msgBus;
    protected $server;

    public function __construct(LoopInterface $loop, MessageBus $msgBus)
    {        
        $this->msgBus = $msgBus;
        $this->server = new Server($loop);      
        $this->server->on("connection", array($this, 'onConnection'));
    }

    public function onConnection(ConnectionInterface $conn)
    {
        $conn->on("data", function($data){
            $this->msgBus->onNotify($data);
        });
    }

    public function listen($ip, $port)
    {
        $this->server->listen($port, $ip);
    }

}

Powered by WebSVN 2.2.1