mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:37:45 +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
|
@ -20,6 +20,11 @@ WebSocket::ReadyState WebSocket::ready_state()
|
|||
return (WebSocket::ReadyState)m_client->ready_state({}, *this);
|
||||
}
|
||||
|
||||
DeprecatedString WebSocket::subprotocol_in_use()
|
||||
{
|
||||
return m_client->subprotocol_in_use({}, *this);
|
||||
}
|
||||
|
||||
void WebSocket::send(ByteBuffer binary_or_text_message, bool is_text)
|
||||
{
|
||||
m_client->send({}, *this, move(binary_or_text_message), is_text);
|
||||
|
|
|
@ -53,6 +53,8 @@ public:
|
|||
|
||||
ReadyState ready_state();
|
||||
|
||||
DeprecatedString subprotocol_in_use();
|
||||
|
||||
void send(ByteBuffer binary_or_text_message, bool is_text);
|
||||
void send(StringView text_message);
|
||||
void close(u16 code = 1005, DeprecatedString reason = {});
|
||||
|
|
|
@ -34,6 +34,13 @@ u32 WebSocketClient::ready_state(Badge<WebSocket>, WebSocket& connection)
|
|||
return IPCProxy::ready_state(connection.id());
|
||||
}
|
||||
|
||||
DeprecatedString WebSocketClient::subprotocol_in_use(Badge<WebSocket>, WebSocket& connection)
|
||||
{
|
||||
if (!m_connections.contains(connection.id()))
|
||||
return DeprecatedString::empty();
|
||||
return IPCProxy::subprotocol_in_use(connection.id());
|
||||
}
|
||||
|
||||
void WebSocketClient::send(Badge<WebSocket>, WebSocket& connection, ByteBuffer data, bool is_text)
|
||||
{
|
||||
if (!m_connections.contains(connection.id()))
|
||||
|
|
|
@ -24,6 +24,7 @@ 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&);
|
||||
DeprecatedString subprotocol_in_use(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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue