summaryrefslogtreecommitdiff
path: root/Ladybird/WebSocketLadybird.h
blob: 170d64b3e4a8e1e759b78d6c7f1761e16ffd5bbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright (c) 2022, Dex♪ <dexes.ttp@gmail.com>
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/WebSockets/WebSocket.h>
#include <LibWebSocket/WebSocket.h>

namespace Ladybird {

class WebSocketLadybird
    : public Web::WebSockets::WebSocketClientSocket
    , public Weakable<WebSocketLadybird> {
public:
    static NonnullRefPtr<WebSocketLadybird> create(NonnullRefPtr<WebSocket::WebSocket>);

    virtual ~WebSocketLadybird() override;

    virtual Web::WebSockets::WebSocket::ReadyState ready_state() override;
    virtual DeprecatedString subprotocol_in_use() override;
    virtual void send(ByteBuffer binary_or_text_message, bool is_text) override;
    virtual void send(StringView message) override;
    virtual void close(u16 code, DeprecatedString reason) override;

private:
    explicit WebSocketLadybird(NonnullRefPtr<WebSocket::WebSocket>);

    NonnullRefPtr<WebSocket::WebSocket> m_websocket;
};

}