protected function startRouterWithTimeout($timeout) { $this->assertNull($this->currentTimer); $this->currentTimer = \EventLoop\addTimer($timeout, function () { \EventLoop\getLoop()->stop(); $this->fail("Router timeout exceeded"); }); $this->router->start(); }
public function start() { $this->loop = \WyriHaximus\Ratchet\loopResolver(); $router = new Router($this->loop); $router->addInternalClient(new InternalClient('first', $this->loop)); $router->addTransportProvider(new RatchetTransportProvider(Configure::read('WyriHaximus.Ratchet.Connection.Websocket.address'), Configure::read('WyriHaximus.Ratchet.Connection.Websocket.port'))); //$router->getRealmManager()->setDefaultAuthorizationManager(new AllPermissiveAuthorizationManager()); EventManager::instance()->dispatch(WebsocketStartEvent::create($this->loop)); $router->start(false); $this->loop->run(); }
/** * @param ConstructEvent $event */ public function construct(ConstructEvent $event) { $router = new Router($event->getLoop()); foreach (Configure::read('WyriHaximus.Ratchet.realms') as $realm => $config) { $router->addInternalClient(new InternalClient($realm, $event->getLoop())); } $router->addTransportProvider(new RatchetTransportProvider(Configure::read('WyriHaximus.Ratchet.internal.address'), Configure::read('WyriHaximus.Ratchet.internal.port'))); //$router->getRealmManager()->setDefaultAuthorizationManager(new AllPermissiveAuthorizationManager()); EventManager::instance()->dispatch(WebsocketStartEvent::create($event->getLoop())); $router->start(false); }
<?php if (file_exists(__DIR__ . '/../../../autoload.php')) { require __DIR__ . '/../../../autoload.php'; } else { require __DIR__ . '/../vendor/autoload.php'; } use Thruway\Peer\Router; use Thruway\Transport\RatchetTransportProvider; $router = new Router(); $transportProvider = new RatchetTransportProvider("0.0.0.0", 6661); $router->addTransportProvider($transportProvider); $router->start();
/** * Test router start * * @return \Thruway\Peer\Router * @throws Exception */ public function testStart() { $this->router->start(); return $this->router; }
/** * Test router start * * @return \Thruway\Peer\Router * @throws Exception */ public function testStart() { $this->router->addTransportProvider($this->transportProviderMock); $this->router->start(); return $this->router; }
/** * Starts the internal router * @return void */ public function start() { $this->router->start(); }