Add support for sending binary data in websockets

Summary:This is a reprise of #6327, but with iOS 7.0 compatibility and less `package.json` changes.

**Test Plan:** Load WebSocketExample in UIExplorer app and start websocket test server script (both provided in #6889) and test sending binary data on both iOS and Android
Closes https://github.com/facebook/react-native/pull/6961

Differential Revision: D3202022

Pulled By: mkonicek

fb-gh-sync-id: 38843d0a9c0172971c5c70a5139ded04042b280a
fbshipit-source-id: 38843d0a9c0172971c5c70a5139ded04042b280a
This commit is contained in:
Philipp von Weitershausen
2016-04-20 08:52:22 -07:00
committed by Facebook Github Bot 8
parent ad15b74aae
commit ed930b4710
4 changed files with 54 additions and 6 deletions

View File

@@ -67,6 +67,12 @@ RCT_EXPORT_METHOD(send:(NSString *)message socketID:(nonnull NSNumber *)socketID
[_sockets[socketID] send:message];
}
RCT_EXPORT_METHOD(sendBinary:(NSString *)base64String socketID:(nonnull NSNumber *)socketID)
{
NSData *message = [[NSData alloc] initWithBase64EncodedString:base64String options:0];
[_sockets[socketID] send:message];
}
RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID)
{
[_sockets[socketID] close];