Devristo\Phpws\Client\WebSocket::close PHP Метод

close() публичный Метод

public close ( )
    public function close()
    {
        if ($this->isClosing) {
            return;
        }
        $this->isClosing = true;
        $this->sendFrame(WebSocketFrame::create(WebSocketOpcode::CloseFrame));
        $this->state = self::STATE_CLOSING;
        $stream = $this->stream;
        $closeTimer = $this->loop->addTimer(5, function () use($stream) {
            $stream->close();
        });
        $loop = $this->loop;
        $stream->once("close", function () use($closeTimer, $loop) {
            if ($closeTimer) {
                $loop->cancelTimer($closeTimer);
            }
        });
    }

Usage Example

Пример #1
0
 /**
  * Disconnect and stop the event loop
  */
 public function stop()
 {
     $this->wsClient->close();
     $this->ariClient->onClose(function () {
         $this->eventLoop->stop();
     });
 }
All Usage Examples Of Devristo\Phpws\Client\WebSocket::close