From 71025c8bcc68929cea2260d92de03e20a3c898d2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 17 Jun 2022 20:29:56 -0700 Subject: Fix most of the errors --- .../jsc/bindings/webcore/WebSocketStream.cpp | 29 +++++++--------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'src/javascript/jsc/bindings/webcore/WebSocketStream.cpp') diff --git a/src/javascript/jsc/bindings/webcore/WebSocketStream.cpp b/src/javascript/jsc/bindings/webcore/WebSocketStream.cpp index 8e059edae..9aa480bbe 100644 --- a/src/javascript/jsc/bindings/webcore/WebSocketStream.cpp +++ b/src/javascript/jsc/bindings/webcore/WebSocketStream.cpp @@ -1,27 +1,14 @@ +#include "root.h" + #include "WebSocketStream.h" +#include "ScriptExecutionContext.h" +#include #include namespace WebCore { template -WebSocketStreamBase* WebSocketStreamBase::adoptSocket(us_socket_t* socket, ScriptExecutionContext* scriptCtx) -{ - using UserData = WebCore::WebSocket; - - /* Adopting a socket invalidates it, do not rely on it directly to carry any data */ - uWS::WebSocket* webSocket = (uWS::WebSocket*)us_socket_context_adopt_socket(SSL, - (us_socket_context_t*)webSocketContext, (us_socket_t*)this, sizeof(WebSocketData) + sizeof(UserData)); - - /* For whatever reason we were corked, update cork to the new socket */ - if (wasCorked) { - webSocket->AsyncSocket::corkUnchecked(); - } - - /* Initialize websocket with any moved backpressure intact */ - webSocket->init(perMessageDeflate, compressOptions, std::move(backpressure)); -} - -void WebSocketStreamBase::registerHTTPContext(ScriptExecutionContext* script, us_socket_context_t* ctx, us_loop_t* loop) +void registerHTTPContextForWebSocket(ScriptExecutionContext* script, us_socket_context_t* ctx, us_loop_t* loop) { if constexpr (!isServer) { if constexpr (SSL) { @@ -35,11 +22,13 @@ void WebSocketStreamBase::registerHTTPContext(ScriptExecutionContext* script, us } template -uWS::WebSocketContext* WebSocketStreamBase::registerClientContext(ScriptExecutionContext*, us_socket_context_t* parent) +uWS::WebSocketContext* registerWebSocketClientContext(ScriptExecutionContext* script, us_socket_context_t* parent) { uWS::Loop* loop = uWS::Loop::get(); - uWS::WebSocketContext* ctx = uWS::WebSocketContext::create(loop, parent, nullptr); + uWS::WebSocketContext* ctx = uWS::WebSocketContext::create(loop, parent, nullptr); auto* opts = ctx->getExt(); + ScriptExecutionContext** scriptCtx = ctx->getUserData(); + *scriptCtx = script; /* Maximum message size we can receive */ static unsigned int maxPayloadLength = 128 * 1024 * 1024; -- cgit v1.2.3