mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Add support for binary type data (ArrayBuffer)
Summary: Entirely based on https://github.com/facebook/react-native/pull/1829 I just updated the diff to be compatible with the current master branch. Closes https://github.com/facebook/react-native/pull/4483 Reviewed By: svcscm Differential Revision: D2783425 Pulled By: nicklockwood fb-gh-sync-id: 1cc67c0741cff3b071530877d688f6b8c1061e3f
This commit is contained in:
committed by
facebook-github-bot-3
parent
6df737d1e7
commit
afbff9bf88
@@ -76,8 +76,10 @@ RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID)
|
||||
|
||||
- (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message
|
||||
{
|
||||
BOOL binary = [message isKindOfClass:[NSData class]];
|
||||
[_bridge.eventDispatcher sendDeviceEventWithName:@"websocketMessage" body:@{
|
||||
@"data": message,
|
||||
@"data": binary ? [message base64EncodedStringWithOptions:0] : message,
|
||||
@"type": binary ? @"binary" : @"text",
|
||||
@"id": webSocket.reactTag
|
||||
}];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user