/* * Copyright (c) 2021, Dex♪ * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Protocol { class WebSocket; class WebSocketClient final : public IPC::ServerConnection , public WebSocketClientEndpoint { C_OBJECT(WebSocketClient); public: RefPtr connect(const URL&, const String& origin = {}, const Vector& protocols = {}, const Vector& extensions = {}, const HashMap& request_headers = {}); u32 ready_state(Badge, WebSocket&); void send(Badge, WebSocket&, ByteBuffer, bool is_text); void close(Badge, WebSocket&, u16 code, String reason); bool set_certificate(Badge, WebSocket&, String, String); private: WebSocketClient(); virtual void connected(i32) override; virtual void received(i32, bool, ByteBuffer const&) override; virtual void errored(i32, i32) override; virtual void closed(i32, u16, String const&, bool) override; virtual void certificate_requested(i32) override; HashMap> m_connections; }; }