WebsocketClient::checkConnection PHP Method

checkConnection() public method

public checkConnection ( )
    public function checkConnection()
    {
        $this->_connected = false;
        // send ping:
        $data = 'ping?';
        @fwrite($this->_Socket, $this->_hybi10Encode($data, 'ping', true));
        $response = @fread($this->_Socket, 300);
        if (empty($response)) {
            return false;
        }
        $response = $this->_hybi10Decode($response);
        if (!is_array($response)) {
            return false;
        }
        if (!isset($response['type']) || $response['type'] !== 'pong') {
            return false;
        }
        $this->_connected = true;
        return true;
    }