diff --git a/change/react-native-windows-52337040-5c5b-4959-95a9-dbf95dd45e4d.json b/change/react-native-windows-52337040-5c5b-4959-95a9-dbf95dd45e4d.json new file mode 100644 index 00000000000..144d17a84b3 --- /dev/null +++ b/change/react-native-windows-52337040-5c5b-4959-95a9-dbf95dd45e4d.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Delete member facebook::react::DevSettings::useWebSocketTurboModule", + "packageName": "react-native-windows", + "email": "julio.rocha@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Shared/DevSettings.h b/vnext/Shared/DevSettings.h index adb4427ff55..3687f686698 100644 --- a/vnext/Shared/DevSettings.h +++ b/vnext/Shared/DevSettings.h @@ -86,9 +86,6 @@ struct DevSettings { bool enableDefaultCrashHandler{false}; - // OC:8368383 - Memory leak under investigation. - bool useWebSocketTurboModule{false}; - // Enable concurrent mode by installing runtimeScheduler bool useRuntimeScheduler{false}; diff --git a/vnext/Shared/Modules/WebSocketModule.cpp b/vnext/Shared/Modules/WebSocketModule.cpp index d4fe2e5f566..7b0f5bb12a9 100644 --- a/vnext/Shared/Modules/WebSocketModule.cpp +++ b/vnext/Shared/Modules/WebSocketModule.cpp @@ -4,7 +4,6 @@ #include "pch.h" #include -#include #include #include diff --git a/vnext/Shared/Modules/WebSocketModule.h b/vnext/Shared/Modules/WebSocketModule.h index 737fe8dbd89..1bdce325438 100644 --- a/vnext/Shared/Modules/WebSocketModule.h +++ b/vnext/Shared/Modules/WebSocketModule.h @@ -3,10 +3,69 @@ #pragma once +#include #include +#include #include -// Windows API -#include +namespace Microsoft::React { -namespace Microsoft::React {} // namespace Microsoft::React +class WebSocketTurboModuleProxy final : public IWebSocketModuleProxy { + std::unordered_map> &m_resourceMap; + + public: + WebSocketTurboModuleProxy( + std::unordered_map> &resourceMap) noexcept; + +#pragma region IWebSocketModuleProxy + + void SendBinary(std::string &&base64String, int64_t id) noexcept override; + +#pragma endregion +}; + +REACT_MODULE(WebSocketTurboModule, L"WebSocketModule") +struct WebSocketTurboModule { + using ModuleSpec = ReactNativeSpecs::WebSocketModuleSpec; + + REACT_INIT(Initialize) + void Initialize(winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept; + + REACT_METHOD(Connect, L"connect") + void Connect( + std::string &&url, + std::optional> protocols, + ReactNativeSpecs::WebSocketModuleSpec_connect_options &&options, + double socketID) noexcept; + + REACT_METHOD(Close, L"close") + void Close(double code, std::string &&reason, double socketID) noexcept; + + REACT_METHOD(Send, L"send") + void Send(std::string &&message, double forSocketID) noexcept; + + REACT_METHOD(SendBinary, L"sendBinary") + void SendBinary(std::string &&base64String, double forSocketID) noexcept; + + REACT_METHOD(Ping, L"ping") + void Ping(double socketID) noexcept; + + REACT_METHOD(AddListener, L"addListener") + void AddListener(std::string &&eventName) noexcept; + + REACT_METHOD(RemoveListeners, L"removeListeners") + void RemoveListeners(double count) noexcept; + + private: + std::shared_ptr CreateResource(int64_t id, std::string &&url) noexcept; + + winrt::Microsoft::ReactNative::ReactContext m_context; + std::unordered_map> m_resourceMap; + + /// + /// Exposes a subset of the module's methods. + /// + std::shared_ptr m_proxy; +}; + +} // namespace Microsoft::React diff --git a/vnext/Shared/Modules/WebSocketTurboModule.h b/vnext/Shared/Modules/WebSocketTurboModule.h deleted file mode 100644 index 1bdce325438..00000000000 --- a/vnext/Shared/Modules/WebSocketTurboModule.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -#pragma once - -#include -#include -#include -#include - -namespace Microsoft::React { - -class WebSocketTurboModuleProxy final : public IWebSocketModuleProxy { - std::unordered_map> &m_resourceMap; - - public: - WebSocketTurboModuleProxy( - std::unordered_map> &resourceMap) noexcept; - -#pragma region IWebSocketModuleProxy - - void SendBinary(std::string &&base64String, int64_t id) noexcept override; - -#pragma endregion -}; - -REACT_MODULE(WebSocketTurboModule, L"WebSocketModule") -struct WebSocketTurboModule { - using ModuleSpec = ReactNativeSpecs::WebSocketModuleSpec; - - REACT_INIT(Initialize) - void Initialize(winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept; - - REACT_METHOD(Connect, L"connect") - void Connect( - std::string &&url, - std::optional> protocols, - ReactNativeSpecs::WebSocketModuleSpec_connect_options &&options, - double socketID) noexcept; - - REACT_METHOD(Close, L"close") - void Close(double code, std::string &&reason, double socketID) noexcept; - - REACT_METHOD(Send, L"send") - void Send(std::string &&message, double forSocketID) noexcept; - - REACT_METHOD(SendBinary, L"sendBinary") - void SendBinary(std::string &&base64String, double forSocketID) noexcept; - - REACT_METHOD(Ping, L"ping") - void Ping(double socketID) noexcept; - - REACT_METHOD(AddListener, L"addListener") - void AddListener(std::string &&eventName) noexcept; - - REACT_METHOD(RemoveListeners, L"removeListeners") - void RemoveListeners(double count) noexcept; - - private: - std::shared_ptr CreateResource(int64_t id, std::string &&url) noexcept; - - winrt::Microsoft::ReactNative::ReactContext m_context; - std::unordered_map> m_resourceMap; - - /// - /// Exposes a subset of the module's methods. - /// - std::shared_ptr m_proxy; -}; - -} // namespace Microsoft::React diff --git a/vnext/Shared/Shared.vcxitems b/vnext/Shared/Shared.vcxitems index bfa815264f4..6e400cfd283 100644 --- a/vnext/Shared/Shared.vcxitems +++ b/vnext/Shared/Shared.vcxitems @@ -325,7 +325,6 @@ - @@ -451,7 +450,7 @@ - + diff --git a/vnext/Shared/Shared.vcxitems.filters b/vnext/Shared/Shared.vcxitems.filters index 2fb11463145..6a8f982e528 100644 --- a/vnext/Shared/Shared.vcxitems.filters +++ b/vnext/Shared/Shared.vcxitems.filters @@ -726,7 +726,6 @@ Header Files\Fabric\platform\react\renderer\core - Header Files\Modules