aboutsummaryrefslogtreecommitdiff
path: root/src/javascript/jsc/bindings/webcore/WebSocketStream.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-17 20:29:56 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-06-22 06:56:47 -0700
commit71025c8bcc68929cea2260d92de03e20a3c898d2 (patch)
tree8dd26d232c82e986a2e775abfb89178b02359596 /src/javascript/jsc/bindings/webcore/WebSocketStream.cpp
parent89f08aae2736182bc681446cab631014f51978a7 (diff)
downloadbun-71025c8bcc68929cea2260d92de03e20a3c898d2.tar.gz
bun-71025c8bcc68929cea2260d92de03e20a3c898d2.tar.zst
bun-71025c8bcc68929cea2260d92de03e20a3c898d2.zip
Fix most of the errors
Diffstat (limited to 'src/javascript/jsc/bindings/webcore/WebSocketStream.cpp')
-rw-r--r--src/javascript/jsc/bindings/webcore/WebSocketStream.cpp29
1 files changed, 9 insertions, 20 deletions
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 <uws/src/App.h>
#include <uws/uSockets/src/libusockets.h>
namespace WebCore {
template<bool SSL, bool isServer>
-WebSocketStreamBase<SSL, isServer>* WebSocketStreamBase<SSL, isServer>::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<SSL, isServer, UserData>* webSocket = (uWS::WebSocket<SSL, isServer, UserData>*)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<SSL>::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<bool SSL, bool isServer>
-uWS::WebSocketContext* WebSocketStreamBase<SSL, isServer>::registerClientContext(ScriptExecutionContext*, us_socket_context_t* parent)
+uWS::WebSocketContext<SSL, isServer, ScriptExecutionContext*>* registerWebSocketClientContext(ScriptExecutionContext* script, us_socket_context_t* parent)
{
uWS::Loop* loop = uWS::Loop::get();
- uWS::WebSocketContext<SSL, isServer>* ctx = uWS::WebSocketContext<SSL, isServer>::create(loop, parent, nullptr);
+ uWS::WebSocketContext<SSL, isServer, ScriptExecutionContext*>* ctx = uWS::WebSocketContext<SSL, isServer>::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;