diff --git a/.github/workflows/unity_build_plugins.yml b/.github/workflows/unity_build_plugins.yml index 8bdcb3d0ab..da100efd8d 100644 --- a/.github/workflows/unity_build_plugins.yml +++ b/.github/workflows/unity_build_plugins.yml @@ -16,6 +16,7 @@ on: - unity/native_src/** - unity/cli/** - unreal/Puerts/Source/JsEnv/Private/V8InspectorImpl.cpp + - unreal/Puerts/Source/JsEnv/Private/WebSocketImpl.cpp - unreal/Puerts/Source/JsEnv/Private/V8InspectorImpl.h - unreal/Puerts/Source/JsEnv/Private/PromiseRejectCallback.hpp - unreal/Puerts/ThirdParty/** diff --git a/.github/workflows/unity_unittest.yml b/.github/workflows/unity_unittest.yml index 96cb2ee4e5..3e2320c64a 100644 --- a/.github/workflows/unity_unittest.yml +++ b/.github/workflows/unity_unittest.yml @@ -10,6 +10,7 @@ on: - unity/cli/** - unreal/Puerts/Source/JsEnv/Private/V8InspectorImpl.cpp - unreal/Puerts/Source/JsEnv/Private/V8InspectorImpl.h + - unreal/Puerts/Source/JsEnv/Private/WebSocketImpl.cpp - unreal/Puerts/Source/JsEnv/Private/PromiseRejectCallback.hpp - .github/workflows/unity_unittest.yml diff --git a/unreal/Puerts/Source/JsEnv/Private/WebSocketImpl.cpp b/unreal/Puerts/Source/JsEnv/Private/WebSocketImpl.cpp index 9b1e6830ea..eaaee2ef3e 100644 --- a/unreal/Puerts/Source/JsEnv/Private/WebSocketImpl.cpp +++ b/unreal/Puerts/Source/JsEnv/Private/WebSocketImpl.cpp @@ -72,14 +72,6 @@ class DataTransfer #endif #endif } - - static v8::Local NewArrayBuffer(v8::Local Context, void* Data, size_t DataLength) - { - v8::Local Ab = v8::ArrayBuffer::New(Context->GetIsolate(), DataLength); - void* Buff = Ab->GetBackingStore()->Data(); - ::memcpy(Buff, Data, DataLength); - return Ab; - } }; #endif @@ -352,8 +344,10 @@ void V8WebSocketClientImpl::OnMessage(wspp_connection_hdl InHandle, wspp_message } else if (InMessage->get_opcode() == websocketpp::frame::opcode::BINARY) { - args[0] = DataTransfer::NewArrayBuffer( - GContext.Get(Isolate), (void*) InMessage->get_payload().data(), InMessage->get_payload().size()); + v8::Local Ab = v8::ArrayBuffer::New(Isolate, InMessage->get_payload().size()); + void* Buff = Ab->GetBackingStore()->Data(); + ::memcpy(Buff, InMessage->get_payload().data(), InMessage->get_payload().size()); + args[0] = Ab; } else {