Thruway\Peer\Router::start PHP Method

start() public method

Start router
public start ( boolean $runLoop = true )
$runLoop boolean
    public function start($runLoop = true)
    {
        Logger::info($this, "Starting router");
        if ($this->loop === null) {
            throw new \Exception("Loop is null");
        }
        $this->started = true;
        $this->eventDispatcher->dispatch("router.start", new RouterStartEvent());
        if ($runLoop) {
            Logger::info($this, "Starting loop");
            $this->loop->run();
        }
    }

Usage Example

示例#1
0
 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();
 }
All Usage Examples Of Thruway\Peer\Router::start