Example #1
0
 /**
  * @override
  */
 public function close($code = 1000)
 {
     if ($this->WebSocket->closing) {
         return;
     }
     if ($code instanceof DataInterface) {
         $this->send($code);
     } else {
         $this->send(new Frame(pack('n', $code), true, Frame::OP_CLOSE));
     }
     $this->connection->close();
     $this->WebSocket->closing = true;
 }
Example #2
0
 /**
  * Close a connection with an HTTP response.
  *
  * @param IoConnectionInterface $conn
  * @param int $code
  * @return null
  */
 protected function close(IoConnectionInterface $conn, $code = 400)
 {
     $response = new HttpResponse($code);
     $conn->send((string) $response);
     $conn->close();
 }
Example #3
0
 /**
  * @override
  * @inheritDoc
  */
 public function handleError(IoConnectionInterface $conn, $ex)
 {
     if (!$this->isBlocked($conn->getHost())) {
         $this->component->handleError($conn, $ex);
     }
 }
Example #4
0
 /**
  * Close a connection with an HTTP response.
  *
  * @param IoConnectionInterface $conn
  * @param int $code
  * @return null
  */
 protected function close(IoConnectionInterface $conn, $code = 400)
 {
     $response = new HttpResponse($code, ['Sec-WebSocket-Version' => $this->wsDriver->getVersionHeader()]);
     $conn->send((string) $response);
     $conn->close();
     unset($conn->WebSocket);
 }