public function disconnect($reason = Protocol::CLOSE_NORMAL): bool
    {
        if ($this->connected === false) {
            return false;
        }

        $payload = $this->protocol->getClosePayload($reason);

        if ($this->socket) {
            if (!$payload->sendToSocket($this->socket)) {
                throw new FrameException("Unexpected exception when sending Close frame.");
            }
            // The client SHOULD wait for the server to close the connection
            $this->socket->receive();
            $this->socket->disconnect();
        }

        $this->connected = false;

        return true;
    }
public function disconnect($reason = Protocol::CLOSE_NORMAL): bool
    {
        if ($this->connected === false) {
            return false;
        }

        $payload = $this->protocol->getClosePayload($reason);

        if ($this->socket) {
            if (!$payload->sendToSocket($this->socket)) {
                throw new FrameException("Unexpected exception when sending Close frame.");
            }
            // The client SHOULD wait for the server to close the connection
            $this->socket->receive();
            $this->socket->disconnect();
        }

        $this->connected = false;

        return true;
    }
public function disconnect ( $ reason = Protocol :: CLOSE_NORMAL ) : bool { if ( $ this -> connected === false ) { return false ; } $ payload = $ this -> protocol -> getClosePayload ( $ reason ) ; if ( $ this -> socket ) { if ( ! $ payload -> sendToSocket ( $ this -> socket ) ) { throw new FrameException ( "Unexpected exception when sending Close frame." ) ; } // The client SHOULD wait for the server to close the connection $ this -> socket -> receive ( ) ; $ this -> socket -> disconnect ( ) ; } $ this -> connected = false ; return true ; }
Disconnects the underlying socket, and marks the client as disconnected

@param int $reason Reason for disconnecting. See Protocol::CLOSE_
@return bool
@throws Exception\SocketException
@throws FrameException
Disconnects the underlying socket and marks the client as disconnected