mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Drop RCT_EXPORT_METHOD from RCTWebSocketModule TurboModule (#57687)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57687 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. Reviewed By: cortinico Differential Revision: D113579874 fbshipit-source-id: 7ffb73d549ab2e81f89a20badbd3a3a1a16de90b
This commit is contained in:
1 parent
2cf34f8799
commit
eda6f4f8ec
1 file changed
+9
-7
@@ -91,10 +91,12 @@ RCT_EXPORT_MODULE()
|
||||
}
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(
|
||||
connect : (NSURL *)URL protocols : (NSArray *)protocols options : (JS::NativeWebSocketModule::SpecConnectOptions &)
|
||||
options socketID : (double)socketID)
|
||||
- (void)connect:(NSString *)urlString
|
||||
protocols:(NSArray *)protocols
|
||||
options:(JS::NativeWebSocketModule::SpecConnectOptions &)options
|
||||
socketID:(double)socketID
|
||||
{
|
||||
NSURL *URL = [RCTConvert NSURL:urlString];
|
||||
if (URL == nil || URL.absoluteString.length == 0u) {
|
||||
RCTAssert(NO, @"RCTWebSocketModule: Invalid WebSocket URL passed to connect");
|
||||
[self sendEventWithName:@"websocketFailed" body:@{@"message" : @"Invalid WebSocket URL", @"id" : @(socketID)}];
|
||||
@@ -167,14 +169,14 @@ RCT_EXPORT_METHOD(
|
||||
[webSocket open];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(send : (NSString *)message forSocketID : (double)socketID)
|
||||
- (void)send:(NSString *)message forSocketID:(double)socketID
|
||||
{
|
||||
SRWebSocket *webSocket = _sockets[@(socketID)];
|
||||
[RCTInspectorWebSocketReporter reportMessageSent:webSocket.inspectorRequestId message:message];
|
||||
[webSocket sendString:message error:nil];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(sendBinary : (NSString *)base64String forSocketID : (double)socketID)
|
||||
- (void)sendBinary:(NSString *)base64String forSocketID:(double)socketID
|
||||
{
|
||||
[self sendData:[[NSData alloc] initWithBase64EncodedString:base64String options:0] forSocketID:@(socketID)];
|
||||
}
|
||||
@@ -186,12 +188,12 @@ RCT_EXPORT_METHOD(sendBinary : (NSString *)base64String forSocketID : (double)so
|
||||
[webSocket sendData:data error:nil];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(ping : (double)socketID)
|
||||
- (void)ping:(double)socketID
|
||||
{
|
||||
[_sockets[@(socketID)] sendPing:nil error:nil];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(close : (double)code reason : (NSString *)reason socketID : (double)socketID)
|
||||
- (void)close:(double)code reason:(NSString *)reason socketID:(double)socketID
|
||||
{
|
||||
[_sockets[@(socketID)] closeWithCode:code reason:reason];
|
||||
[_sockets removeObjectForKey:@(socketID)];
|
||||
|
||||
Reference in new issue
Block a user