public function handleConnect($server, $socket) { $socket->conn = new NetworkConnection($socket); try { $this->component->handleConnect($socket->conn); $socket->on('data', [$this, 'handleData']); $socket->on('error', [$this, 'handleError']); $socket->on('close', [$this, 'handleDisconnect']); } catch (Error $ex) { $this->close($socket); } catch (Exception $ex) { $this->close($socket); } }