Skip to content

Commit f50086e

Browse files
Drop RCT_EXPORT_METHOD from RCTWebSocketModule TurboModule
Summary: Changelog: [Internal] `RCTWebSocketModule` is a TurboModule: it conforms to `NativeWebSocketModuleSpec` and implements `getTurboModule:` returning the codegen'd `...SpecJSI`. For TurboModules, the JS->ObjC dispatch is driven by codegen (the generated spec supplies the `selector` and argument kinds, invoked at runtime via `NSMethodSignature` / `NSInvocation`), not by the `RCT_EXPORT_METHOD` macro's `__rct_export__` metadata. The exported methods here are async-void with concrete parameter types (no generic `id` requiring `RCTConvert` coercion), so the macro is not functionally required. Convert them to plain ObjC method declarations; conformance to the codegen'd `NativeWebSocketModuleSpec` protocol keeps compiler-enforced signature parity. Signature-only refactor with no change to the JS-facing API. Sync methods, methods with `id` params, and `constantsToExport` are intentionally left untouched. Differential Revision: D113579874
1 parent 285f7b5 commit f50086e

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

packages/react-native/React/CoreModules/RCTWebSocketModule.mm

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ - (void)invalidate
9191
}
9292
}
9393

94-
RCT_EXPORT_METHOD(
95-
connect : (NSURL *)URL protocols : (NSArray *)protocols options : (JS::NativeWebSocketModule::SpecConnectOptions &)
96-
options socketID : (double)socketID)
94+
- (void)connect:(NSString *)urlString
95+
protocols:(NSArray *)protocols
96+
options:(JS::NativeWebSocketModule::SpecConnectOptions &)options
97+
socketID:(double)socketID
9798
{
99+
NSURL *URL = [RCTConvert NSURL:urlString];
98100
if (URL == nil || URL.absoluteString.length == 0u) {
99101
RCTAssert(NO, @"RCTWebSocketModule: Invalid WebSocket URL passed to connect");
100102
[self sendEventWithName:@"websocketFailed" body:@{@"message" : @"Invalid WebSocket URL", @"id" : @(socketID)}];
@@ -167,14 +169,14 @@ - (void)invalidate
167169
[webSocket open];
168170
}
169171

170-
RCT_EXPORT_METHOD(send : (NSString *)message forSocketID : (double)socketID)
172+
- (void)send:(NSString *)message forSocketID:(double)socketID
171173
{
172174
SRWebSocket *webSocket = _sockets[@(socketID)];
173175
[RCTInspectorWebSocketReporter reportMessageSent:webSocket.inspectorRequestId message:message];
174176
[webSocket sendString:message error:nil];
175177
}
176178

177-
RCT_EXPORT_METHOD(sendBinary : (NSString *)base64String forSocketID : (double)socketID)
179+
- (void)sendBinary:(NSString *)base64String forSocketID:(double)socketID
178180
{
179181
[self sendData:[[NSData alloc] initWithBase64EncodedString:base64String options:0] forSocketID:@(socketID)];
180182
}
@@ -186,12 +188,12 @@ - (void)sendData:(NSData *)data forSocketID:(NSNumber *__nonnull)socketID
186188
[webSocket sendData:data error:nil];
187189
}
188190

189-
RCT_EXPORT_METHOD(ping : (double)socketID)
191+
- (void)ping:(double)socketID
190192
{
191193
[_sockets[@(socketID)] sendPing:nil error:nil];
192194
}
193195

194-
RCT_EXPORT_METHOD(close : (double)code reason : (NSString *)reason socketID : (double)socketID)
196+
- (void)close:(double)code reason:(NSString *)reason socketID:(double)socketID
195197
{
196198
[_sockets[@(socketID)] closeWithCode:code reason:reason];
197199
[_sockets removeObjectForKey:@(socketID)];

0 commit comments

Comments
 (0)