Skip to content
Closed
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
21 changes: 9 additions & 12 deletions packages/react-native/Libraries/Blob/RCTBlobManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ - (void)remove:(NSString *)blobId
[_blobs removeObjectForKey:blobId];
}

RCT_EXPORT_METHOD(addNetworkingHandler)
- (void)addNetworkingHandler
{
RCTNetworking *const networking = [_moduleRegistry moduleForName:"Networking"];

Expand All @@ -164,32 +164,29 @@ - (void)remove:(NSString *)blobId
});
}

RCT_EXPORT_METHOD(addWebSocketHandler : (double)socketID)
- (void)addWebSocketHandler:(double)socketID
{
dispatch_async(((RCTWebSocketModule *)[_moduleRegistry moduleForName:"WebSocketModule"]).methodQueue, ^{
[[self->_moduleRegistry moduleForName:"WebSocketModule"] setContentHandler:self
forSocketID:[NSNumber numberWithDouble:socketID]];
[[self->_moduleRegistry moduleForName:"WebSocketModule"] setContentHandler:self forSocketID:@(socketID)];
});
}

RCT_EXPORT_METHOD(removeWebSocketHandler : (double)socketID)
- (void)removeWebSocketHandler:(double)socketID
{
dispatch_async(((RCTWebSocketModule *)[_moduleRegistry moduleForName:"WebSocketModule"]).methodQueue, ^{
[[self->_moduleRegistry moduleForName:"WebSocketModule"] setContentHandler:nil
forSocketID:[NSNumber numberWithDouble:socketID]];
[[self->_moduleRegistry moduleForName:"WebSocketModule"] setContentHandler:nil forSocketID:@(socketID)];
});
}

// @lint-ignore FBOBJCUNTYPEDCOLLECTION1
RCT_EXPORT_METHOD(sendOverSocket : (NSDictionary *)blob socketID : (double)socketID)
- (void)sendOverSocket:(NSDictionary *)blob socketID:(double)socketID
{
dispatch_async(((RCTWebSocketModule *)[_moduleRegistry moduleForName:"WebSocketModule"]).methodQueue, ^{
[[self->_moduleRegistry moduleForName:"WebSocketModule"] sendData:[self resolve:blob]
forSocketID:[NSNumber numberWithDouble:socketID]];
[[self->_moduleRegistry moduleForName:"WebSocketModule"] sendData:[self resolve:blob] forSocketID:@(socketID)];
});
}

RCT_EXPORT_METHOD(createFromParts : (NSArray<NSDictionary<NSString *, id> *> *)parts withId : (NSString *)blobId)
- (void)createFromParts:(NSArray<NSDictionary<NSString *, id> *> *)parts withId:(NSString *)blobId
{
NSMutableData *data = [NSMutableData new];
for (NSDictionary<NSString *, id> *part in parts) {
Expand All @@ -211,7 +208,7 @@ - (void)remove:(NSString *)blobId
});
}

RCT_EXPORT_METHOD(release : (NSString *)blobId)
- (void)release:(NSString *)blobId
{
dispatch_async(_methodQueue, ^{
[self remove:blobId];
Expand Down
Loading