mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27: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
|
@ -87,6 +87,11 @@ Web::WebSockets::WebSocket::ReadyState WebSocketClientSocketAdapter::ready_state
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
DeprecatedString WebSocketClientSocketAdapter::subprotocol_in_use()
|
||||
{
|
||||
return m_websocket->subprotocol_in_use();
|
||||
}
|
||||
|
||||
void WebSocketClientSocketAdapter::send(ByteBuffer binary_or_text_message, bool is_text)
|
||||
{
|
||||
m_websocket->send(binary_or_text_message, is_text);
|
||||
|
@ -115,9 +120,9 @@ WebSocketClientManagerAdapter::WebSocketClientManagerAdapter(NonnullRefPtr<Proto
|
|||
|
||||
WebSocketClientManagerAdapter::~WebSocketClientManagerAdapter() = default;
|
||||
|
||||
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerAdapter::connect(const AK::URL& url, DeprecatedString const& origin)
|
||||
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerAdapter::connect(const AK::URL& url, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols)
|
||||
{
|
||||
auto underlying_websocket = m_websocket_client->connect(url, origin);
|
||||
auto underlying_websocket = m_websocket_client->connect(url, origin, protocols);
|
||||
if (!underlying_websocket)
|
||||
return {};
|
||||
return WebSocketClientSocketAdapter::create(underlying_websocket.release_nonnull());
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
virtual ~WebSocketClientSocketAdapter() 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 text_message) override;
|
||||
|
@ -43,7 +44,7 @@ public:
|
|||
|
||||
virtual ~WebSocketClientManagerAdapter() override;
|
||||
|
||||
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> connect(const AK::URL&, DeprecatedString const& origin) override;
|
||||
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> connect(const AK::URL&, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols) override;
|
||||
|
||||
private:
|
||||
WebSocketClientManagerAdapter(NonnullRefPtr<Protocol::WebSocketClient>);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue