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