Esempio n. 1
0
 /**
  * @param IoConnectionInterface $conn
  */
 protected function attemptUpgrade(IoConnectionInterface $conn)
 {
     $request = $conn->WebSocket->request;
     if (!$this->wsDriver->isVersionEnabled($request)) {
         return $this->close($conn);
     }
     $conn->WebSocket->version = $this->wsDriver->getVersion($request);
     try {
         $response = $conn->WebSocket->version->wsHandshake($request);
     } catch (Error $ex) {
         return;
     } catch (Exception $ex) {
         return;
     }
     //        $agreedSubProtocols = $this->getSubProtocolString($request->getHeader('Sec-WebSocket-Protocol'));
     //
     //        if ($agreedSubProtocols !== '')
     //        {
     //            $response->setHeader('Sec-WebSocket-Protocol', $agreedSubProtocols);
     //        }
     $conn->send((string) $response);
     if ($response->getStatusCode() !== 101) {
         return $conn->close();
     }
     $upgraded = $conn->WebSocket->version->wsUpgrade($conn, $this->wsServer);
     $this->connectionCollection->attach($conn, $upgraded);
     $upgraded->WebSocket->established = true;
     $this->wsServer->handleConnect($upgraded);
 }
Esempio n. 2
0
 /**
  * @override
  */
 public function handleError(IoConnectionInterface $conn, $ex)
 {
     if ($conn->httpHeadersReceived) {
         $this->httpServer->handleError($conn, $ex);
     } else {
         $this->close($conn, 500);
     }
 }
Esempio n. 3
0
 /**
  * Handler triggered when an error has occured during doing operation on existing connection.
  *
  * @param SocketInterface $socket
  * @param Error|Exception $ex
  */
 public function handleError($socket, $ex)
 {
     try {
         $this->component->handleError($socket->conn, $ex);
     } catch (Error $ex) {
         $this->close($socket);
     } catch (Exception $ex) {
         $this->close($socket);
     }
 }
Esempio n. 4
0
 /**
  * @override
  * @inheritDoc
  */
 public function handleError(IoConnectionInterface $conn, $ex)
 {
     if (!$this->isBlocked($conn->getHost())) {
         $this->component->handleError($conn, $ex);
     }
 }
Esempio n. 5
0
 /**
  * @override
  * @inheritDoc
  */
 public function handleError(IoConnectionInterface $conn, $ex)
 {
     return $this->component->handleError($conn, $ex);
 }