mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
Everywhere: Merge the WebSocket service into RequestServer
This keeps the APIs separate as they are wildly different, a future improvement could be to somehow unify the APIs (if possible). Closes #23080.
This commit is contained in:
parent
daf5484d6b
commit
6dfb2f9dc8
56 changed files with 231 additions and 845 deletions
|
@ -4,8 +4,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibProtocol/RequestClient.h>
|
||||
#include <LibProtocol/WebSocket.h>
|
||||
#include <LibProtocol/WebSocketClient.h>
|
||||
#include <LibWebView/WebSocketClientAdapter.h>
|
||||
|
||||
namespace WebView {
|
||||
|
@ -107,30 +107,4 @@ void WebSocketClientSocketAdapter::close(u16 code, ByteString reason)
|
|||
m_websocket->close(code, reason);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<WebSocketClientManagerAdapter>> WebSocketClientManagerAdapter::try_create(NonnullRefPtr<Protocol::WebSocketClient> websocket_client)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) WebSocketClientManagerAdapter(move(websocket_client)));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<WebSocketClientManagerAdapter>> WebSocketClientManagerAdapter::try_create()
|
||||
{
|
||||
auto websocket_client = TRY(Protocol::WebSocketClient::try_create());
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) WebSocketClientManagerAdapter(move(websocket_client)));
|
||||
}
|
||||
|
||||
WebSocketClientManagerAdapter::WebSocketClientManagerAdapter(NonnullRefPtr<Protocol::WebSocketClient> websocket_client)
|
||||
: m_websocket_client(move(websocket_client))
|
||||
{
|
||||
}
|
||||
|
||||
WebSocketClientManagerAdapter::~WebSocketClientManagerAdapter() = default;
|
||||
|
||||
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerAdapter::connect(const URL& url, ByteString const& origin, Vector<ByteString> const& protocols)
|
||||
{
|
||||
auto underlying_websocket = m_websocket_client->connect(url, origin, protocols);
|
||||
if (!underlying_websocket)
|
||||
return {};
|
||||
return WebSocketClientSocketAdapter::create(underlying_websocket.release_nonnull());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue