aboutsummaryrefslogtreecommitdiff
path: root/src/javascript/jsc/bindings/ScriptExecutionContext.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-22 23:21:48 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-22 23:21:48 -0700
commit729d445b6885f69dd2c6355f38707bd42851c791 (patch)
treef87a7c408929ea3f57bbb7ace380cf869da83c0e /src/javascript/jsc/bindings/ScriptExecutionContext.cpp
parent25f820c6bf1d8ec6d444ef579cc036b8c0607b75 (diff)
downloadbun-jarred/rename.tar.gz
bun-jarred/rename.tar.zst
bun-jarred/rename.zip
change the directory structurejarred/rename
Diffstat (limited to 'src/javascript/jsc/bindings/ScriptExecutionContext.cpp')
-rw-r--r--src/javascript/jsc/bindings/ScriptExecutionContext.cpp81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/javascript/jsc/bindings/ScriptExecutionContext.cpp b/src/javascript/jsc/bindings/ScriptExecutionContext.cpp
deleted file mode 100644
index 73b8b4c01..000000000
--- a/src/javascript/jsc/bindings/ScriptExecutionContext.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "root.h"
-#include "headers.h"
-#include "ScriptExecutionContext.h"
-
-#include "webcore/WebSocket.h"
-
-#include <uws/src/App.h>
-
-extern "C" void Bun__startLoop(us_loop_t* loop);
-
-namespace WebCore {
-
-template<bool SSL, bool isServer>
-static void registerHTTPContextForWebSocket(ScriptExecutionContext* script, us_socket_context_t* ctx, us_loop_t* loop)
-{
- if constexpr (!isServer) {
- if constexpr (SSL) {
- Bun__WebSocketHTTPSClient__register(script->jsGlobalObject(), loop, ctx);
- } else {
- Bun__WebSocketHTTPClient__register(script->jsGlobalObject(), loop, ctx);
- }
- } else {
- RELEASE_ASSERT_NOT_REACHED();
- }
-}
-
-us_socket_context_t* ScriptExecutionContext::webSocketContextSSL()
-{
- if (!m_ssl_client_websockets_ctx) {
- us_loop_t* loop = (us_loop_t*)uWS::Loop::get();
- us_socket_context_options_t opts;
- memset(&opts, 0, sizeof(us_socket_context_options_t));
- this->m_ssl_client_websockets_ctx = us_create_socket_context(1, loop, sizeof(size_t), opts);
- void** ptr = reinterpret_cast<void**>(us_socket_context_ext(1, m_ssl_client_websockets_ctx));
- *ptr = this;
- registerHTTPContextForWebSocket<true, false>(this, m_ssl_client_websockets_ctx, loop);
- }
-
- return m_ssl_client_websockets_ctx;
-}
-
-us_socket_context_t* ScriptExecutionContext::webSocketContextNoSSL()
-{
- if (!m_client_websockets_ctx) {
- us_loop_t* loop = (us_loop_t*)uWS::Loop::get();
- us_socket_context_options_t opts;
- memset(&opts, 0, sizeof(us_socket_context_options_t));
- this->m_client_websockets_ctx = us_create_socket_context(0, loop, sizeof(size_t), opts);
- void** ptr = reinterpret_cast<void**>(us_socket_context_ext(0, m_client_websockets_ctx));
- *ptr = this;
- registerHTTPContextForWebSocket<false, false>(this, m_client_websockets_ctx, loop);
- }
-
- return m_client_websockets_ctx;
-}
-
-template<bool SSL>
-static us_socket_context_t* registerWebSocketClientContext(ScriptExecutionContext* script, us_socket_context_t* parent)
-{
- us_loop_t* loop = (us_loop_t*)uWS::Loop::get();
- if constexpr (SSL) {
- us_socket_context_t* child = us_create_child_socket_context(1, parent, sizeof(size_t));
- Bun__WebSocketClientTLS__register(script->jsGlobalObject(), loop, child);
- return child;
- } else {
- us_socket_context_t* child = us_create_child_socket_context(0, parent, sizeof(size_t));
- Bun__WebSocketClient__register(script->jsGlobalObject(), loop, child);
- return child;
- }
-}
-
-us_socket_context_t* ScriptExecutionContext::connectedWebSocketKindClient()
-{
- return registerWebSocketClientContext<false>(this, webSocketContextNoSSL());
-}
-us_socket_context_t* ScriptExecutionContext::connectedWebSocketKindClientSSL()
-{
- return registerWebSocketClientContext<true>(this, webSocketContextSSL());
-}
-
-} \ No newline at end of file