Exemplo n.º 1
0
 /**
  * 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"]);
 }
 /**
  * Handle process reveiced data
  * 
  * @param mixed $data
  * @param \React\Stream\Stream $conn
  */
 public function handleData($data, Stream $conn)
 {
     $this->transport->handleData($data);
 }