/** * Handle process on open new connection * * @param \React\Stream\Stream $conn */ public function handleConnection(Stream $conn) { //$this->getManager()->debug("Raw socket opened"); $this->transport = new RawSocketTransport($conn, $this->loop, $this->peer); $this->transport->setSerializer(new JsonSerializer()); $this->transport->setTrusted($this->trusted); $this->peer->onOpen($this->transport); }
/** * Handle process on open new connection * * @param \React\Socket\Connection $conn */ public function handleConnection(Connection $conn) { Logger::debug($this, "Raw socket opened " . $conn->getRemoteAddress()); $transport = new RawSocketTransport($conn, $this->loop, $this->router); $transport->setSerializer(new JsonSerializer()); $transport->setTrusted($this->trusted); $session = $this->router->createNewSession($transport); $this->sessions->attach($conn, $session); $transport->on('message', function ($transport, $msg) use($session) { $session->dispatchMessage($msg); }); $this->router->getEventDispatcher()->dispatch("connection_open", new ConnectionOpenEvent($session)); $conn->on('data', [$transport, "handleData"]); $conn->on('close', [$this, "handleClose"]); }