Backed out changeset 183744d2415b

Reviewed By: nicklockwood

Differential Revision: D3053067

fb-gh-sync-id: de20718b5bf82eae433637847143e32b7a4bb216
shipit-source-id: de20718b5bf82eae433637847143e32b7a4bb216
This commit is contained in:
Alexey Dodonov
2016-03-15 11:48:42 -07:00
committed by Facebook Github Bot 6
parent fe7fcdb227
commit cc2068e201
5 changed files with 73 additions and 30 deletions

View File

@@ -11,6 +11,7 @@
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"
#import "RCTConvert.h"
#import "RCTUtils.h"
@implementation RCTSRWebSocket (React)
@@ -44,9 +45,14 @@ RCT_EXPORT_MODULE()
}
}
RCT_EXPORT_METHOD(connect:(NSURL *)URL protocols:(NSArray *)protocols options:(NSDictionary *)options socketID:(nonnull NSNumber *)socketID)
RCT_EXPORT_METHOD(connect:(NSURL *)URL protocols:(NSArray *)protocols headers:(NSDictionary *)headers socketID:(nonnull NSNumber *)socketID)
{
RCTSRWebSocket *webSocket = [[RCTSRWebSocket alloc] initWithURL:URL protocols:protocols options:options];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[headers enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) {
[request addValue:[RCTConvert NSString:value] forHTTPHeaderField:key];
}];
RCTSRWebSocket *webSocket = [[RCTSRWebSocket alloc] initWithURLRequest:request protocols:protocols];
webSocket.delegate = self;
webSocket.reactTag = socketID;
if (!_sockets) {