Changed the host for RCTWebSocketExecutor to the one retrieved from the bridge.

Reviewed By: javache

Differential Revision: D3425043

fbshipit-source-id: 342d3dfede6a29197dedb68278ee088dcf009e16
This commit is contained in:
Nathan Azaria 2016-06-13 13:15:30 -07:00 committed by Facebook Github Bot 8
parent a4f772f5f7
commit 9443bc5c3f
1 changed files with 8 additions and 1 deletions

View File

@ -13,6 +13,7 @@
#import "RCTWebSocketExecutor.h"
#import "RCTBridge.h"
#import "RCTConvert.h"
#import "RCTLog.h"
#import "RCTUtils.h"
@ -36,6 +37,8 @@ typedef void (^RCTWSMessageCallback)(NSError *error, NSDictionary<NSString *, id
RCT_EXPORT_MODULE()
@synthesize bridge = _bridge;
- (instancetype)initWithURL:(NSURL *)URL
{
RCTAssertParam(URL);
@ -51,7 +54,11 @@ RCT_EXPORT_MODULE()
if (!_url) {
NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults];
NSInteger port = [standardDefaults integerForKey:@"websocket-executor-port"] ?: 8081;
NSString *URLString = [NSString stringWithFormat:@"http://localhost:%zd/debugger-proxy?role=client", port];
NSString *host = [[_bridge bundleURL] host];
if (!host) {
host = @"localhost";
}
NSString *URLString = [NSString stringWithFormat:@"http://%@:%zd/debugger-proxy?role=client", host, port];
_url = [RCTConvert NSURL:URLString];
}