mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:07:34 +00:00
LibWeb+LibWebSocket: DOM WebSocket subprotocol support
This adds support for WebSocket subprotocols to WebSocket DOM objects, with some necessary plumbing to LibWebSocket and its clients. See the associated pull request for how this was tested.
This commit is contained in:
parent
9115e99e4b
commit
230c0b34d4
19 changed files with 107 additions and 34 deletions
|
@ -19,10 +19,11 @@ NonnullRefPtr<WebSocketClientManagerLadybird> WebSocketClientManagerLadybird::cr
|
|||
WebSocketClientManagerLadybird::WebSocketClientManagerLadybird() = default;
|
||||
WebSocketClientManagerLadybird::~WebSocketClientManagerLadybird() = default;
|
||||
|
||||
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerLadybird::connect(AK::URL const& url, DeprecatedString const& origin)
|
||||
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerLadybird::connect(AK::URL const& url, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols)
|
||||
{
|
||||
WebSocket::ConnectionInfo connection_info(url);
|
||||
connection_info.set_origin(origin);
|
||||
connection_info.set_protocols(protocols);
|
||||
|
||||
auto impl = adopt_ref(*new WebSocketImplQt);
|
||||
auto web_socket = WebSocket::WebSocket::create(move(connection_info), move(impl));
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
static NonnullRefPtr<WebSocketClientManagerLadybird> create();
|
||||
|
||||
virtual ~WebSocketClientManagerLadybird() override;
|
||||
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> connect(AK::URL const&, DeprecatedString const& origin) override;
|
||||
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> connect(AK::URL const&, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols) override;
|
||||
|
||||
private:
|
||||
WebSocketClientManagerLadybird();
|
||||
|
|
|
@ -74,6 +74,11 @@ Web::WebSockets::WebSocket::ReadyState WebSocketLadybird::ready_state()
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
DeprecatedString WebSocketLadybird::subprotocol_in_use()
|
||||
{
|
||||
return m_websocket->subprotocol_in_use();
|
||||
}
|
||||
|
||||
void WebSocketLadybird::send(ByteBuffer binary_or_text_message, bool is_text)
|
||||
{
|
||||
m_websocket->send(WebSocket::Message(binary_or_text_message, is_text));
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue