mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 05:35:52 +03:00
230c0b34d4
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.
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2022, Dex♪ <dexes.ttp@gmail.com>
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "WebSocketClientManagerLadybird.h"
|
|
#include "WebSocketImplQt.h"
|
|
#include "WebSocketLadybird.h"
|
|
|
|
namespace Ladybird {
|
|
|
|
NonnullRefPtr<WebSocketClientManagerLadybird> WebSocketClientManagerLadybird::create()
|
|
{
|
|
return adopt_ref(*new WebSocketClientManagerLadybird());
|
|
}
|
|
|
|
WebSocketClientManagerLadybird::WebSocketClientManagerLadybird() = default;
|
|
WebSocketClientManagerLadybird::~WebSocketClientManagerLadybird() = default;
|
|
|
|
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));
|
|
web_socket->start();
|
|
return WebSocketLadybird::create(web_socket);
|
|
}
|
|
|
|
}
|