2022-09-19 09:16:42 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
2022-11-08 18:17:53 +00:00
|
|
|
#include "WebSocketImplQt.h"
|
2022-09-19 09:16:42 +00:00
|
|
|
#include "WebSocketLadybird.h"
|
|
|
|
|
|
|
|
namespace Ladybird {
|
|
|
|
|
|
|
|
NonnullRefPtr<WebSocketClientManagerLadybird> WebSocketClientManagerLadybird::create()
|
|
|
|
{
|
|
|
|
return adopt_ref(*new WebSocketClientManagerLadybird());
|
|
|
|
}
|
|
|
|
|
|
|
|
WebSocketClientManagerLadybird::WebSocketClientManagerLadybird() = default;
|
|
|
|
WebSocketClientManagerLadybird::~WebSocketClientManagerLadybird() = default;
|
|
|
|
|
2022-12-31 10:37:10 +00:00
|
|
|
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerLadybird::connect(AK::URL const& url, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols)
|
2022-09-19 09:16:42 +00:00
|
|
|
{
|
|
|
|
WebSocket::ConnectionInfo connection_info(url);
|
|
|
|
connection_info.set_origin(origin);
|
2022-12-31 10:37:10 +00:00
|
|
|
connection_info.set_protocols(protocols);
|
2022-09-19 09:16:42 +00:00
|
|
|
|
2022-11-08 18:17:53 +00:00
|
|
|
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);
|
2022-09-19 09:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|