/** * @param int $timeout * @param callable $callback * @return $this|ServerInterface */ public function listen($timeout, callable $callback) { $this->on(['connection'], $callback); if ($this->registeredListener !== true) { $server = $this; \uv_listen($this->connection, $timeout, function () use($server) { $client = new Client($this->getServiceManager(), $this->getLoop()); $client->accept($server); $server->emit(new Event('connection'), [$client, $server]); $client->poll(); }); } return $this; }