freenet-router |
Subversion Repositories: |
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);
}
}