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:
Johan Lindskogen
2015-12-22 09:22:01 -08:00
committed by facebook-github-bot-3
parent 6df737d1e7
commit afbff9bf88
4 changed files with 66 additions and 56 deletions

View File

@@ -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
}];
}