Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Delete member facebook::react::DevSettings::useWebSocketTurboModule",
"packageName": "react-native-windows",
"email": "julio.rocha@microsoft.com",
"dependentChangeType": "patch"
}
3 changes: 0 additions & 3 deletions vnext/Shared/DevSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
1 change: 0 additions & 1 deletion vnext/Shared/Modules/WebSocketModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "pch.h"

#include <Modules/WebSocketModule.h>
#include <Modules/WebSocketTurboModule.h>

#include <CreateModules.h>
#include <Modules/CxxModuleUtilities.h>
Expand Down
65 changes: 62 additions & 3 deletions vnext/Shared/Modules/WebSocketModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,69 @@

#pragma once

#include <codegen/NativeWebSocketModuleSpec.g.h>
#include <Modules/IWebSocketModuleProxy.h>
#include <NativeModules.h>
#include <Networking/IWebSocketResource.h>

// Windows API
#include <winrt/Windows.Foundation.h>
namespace Microsoft::React {

namespace Microsoft::React {} // namespace Microsoft::React
class WebSocketTurboModuleProxy final : public IWebSocketModuleProxy {
std::unordered_map<double, std::shared_ptr<Networking::IWebSocketResource>> &m_resourceMap;

public:
WebSocketTurboModuleProxy(
std::unordered_map<double, std::shared_ptr<Networking::IWebSocketResource>> &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<std::vector<std::string>> 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<Networking::IWebSocketResource> CreateResource(int64_t id, std::string &&url) noexcept;

winrt::Microsoft::ReactNative::ReactContext m_context;
std::unordered_map<double, std::shared_ptr<Networking::IWebSocketResource>> m_resourceMap;

/// <summary>
/// Exposes a subset of the module's methods.
/// </summary>
std::shared_ptr<IWebSocketModuleProxy> m_proxy;
};

} // namespace Microsoft::React
71 changes: 0 additions & 71 deletions vnext/Shared/Modules/WebSocketTurboModule.h

This file was deleted.

3 changes: 1 addition & 2 deletions vnext/Shared/Shared.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IWebSocketModuleContentHandler.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\IWebSocketModuleProxy.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\HttpModule.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\WebSocketTurboModule.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\DefaultBlobResource.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\IBlobResource.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\IHttpResource.h" />
Expand Down Expand Up @@ -451,7 +450,7 @@
<CLCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\featureflags\NativeReactNativeFeatureFlags.cpp" />
<CLCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\dom\NativeDOM.cpp" DisableSpecificWarnings="4715;%(DisableSpecificWarnings)" />
<CLCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\idlecallbacks\NativeIdleCallbacks.cpp" />
<CLCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\webperformance\NativePerformance.cpp" />
<CLCompile Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\webperformance\NativePerformance.cpp" />
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\attributedstring\AttributedString.cpp" />
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\attributedstring\AttributedStringBox.cpp" DisableSpecificWarnings="4715;%(DisableSpecificWarnings)" />
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\view\BaseViewProps.cpp" DisableSpecificWarnings="4459;4715;%(DisableSpecificWarnings)" />
Expand Down
1 change: 0 additions & 1 deletion vnext/Shared/Shared.vcxitems.filters
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\platform\react\renderer\core\graphicsConversions.h">
<Filter>Header Files\Fabric\platform\react\renderer\core</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)Modules\WebSocketTurboModule.h">
<Filter>Header Files\Modules</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)Networking\IBlobResource.h">
Expand Down
Loading