ladybird/Userland/Libraries/LibProtocol/WebSocketClient.h
Linus Groh 6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00

43 lines
1.5 KiB
C++

/*
* Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include <LibIPC/ConnectionToServer.h>
#include <WebSocket/WebSocketClientEndpoint.h>
#include <WebSocket/WebSocketServerEndpoint.h>
namespace Protocol {
class WebSocket;
class WebSocketClient final
: public IPC::ConnectionToServer<WebSocketClientEndpoint, WebSocketServerEndpoint>
, public WebSocketClientEndpoint {
IPC_CLIENT_CONNECTION(WebSocketClient, "/tmp/session/%sid/portal/websocket"sv)
public:
RefPtr<WebSocket> connect(const URL&, DeprecatedString const& origin = {}, Vector<DeprecatedString> const& protocols = {}, Vector<DeprecatedString> const& extensions = {}, HashMap<DeprecatedString, DeprecatedString> const& request_headers = {});
u32 ready_state(Badge<WebSocket>, WebSocket&);
void send(Badge<WebSocket>, WebSocket&, ByteBuffer, bool is_text);
void close(Badge<WebSocket>, WebSocket&, u16 code, DeprecatedString reason);
bool set_certificate(Badge<WebSocket>, WebSocket&, DeprecatedString, DeprecatedString);
private:
WebSocketClient(NonnullOwnPtr<Core::Stream::LocalSocket>);
virtual void connected(i32) override;
virtual void received(i32, bool, ByteBuffer const&) override;
virtual void errored(i32, i32) override;
virtual void closed(i32, u16, DeprecatedString const&, bool) override;
virtual void certificate_requested(i32) override;
HashMap<i32, NonnullRefPtr<WebSocket>> m_connections;
};
}