Skip to content

Commit

Permalink
feat(ios): add clientId and fix empty port (#1737)
Browse files Browse the repository at this point in the history
* feat(ios): devtools modify debugURL key

* feat(ios): add clientId and fix empty port

Co-authored-by: luomy <mengyanluo@tencent.com>
  • Loading branch information
2 people authored and zoomchan-cxj committed Apr 27, 2022
1 parent 5654164 commit aea12a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ios/sdk/base/executors/HippyJSCExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ static unicode_string_view NSStringToU8(NSString* str) {
[deviceInfo addEntriesFromDictionary:customObjects];
}
}
NSString *deviceName = [[UIDevice currentDevice] name];
NSString *clientId = HippyMD5Hash([NSString stringWithFormat:@"%@%p", deviceName, strongSelf.bridge]);
NSDictionary *debugInfo = @{@"Debug" : @{@"debugClientId" : clientId}};
[deviceInfo addEntriesFromDictionary:debugInfo];
NSError *JSONSerializationError = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:deviceInfo options:0 error:&JSONSerializationError];
if (JSONSerializationError) {
Expand Down
6 changes: 5 additions & 1 deletion ios/sdk/debug/devtools/HippyDevWebSocketClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ - (instancetype)initWithDevInfo:(HippyDevInfo *)devInfo contextName:(NSString *)
NSString *encodeName = [contextName stringByAddingPercentEncodingWithAllowedCharacters:allowedChar];
NSString *deviceName = [[UIDevice currentDevice] name];
NSString *encodedDeviceName = [deviceName stringByAddingPercentEncodingWithAllowedCharacters:allowedChar];
NSString *addressPrefix = [NSString stringWithFormat:@"%@://%@:%@/debugger-proxy", devInfo.scheme, devInfo.ipAddress, devInfo.port?:@"38989"];
NSString *port = devInfo.port;
if (port.length <= 0) {
port = [devInfo.scheme isEqualToString:@"wss"] ? @"443": @"80";
}
NSString *addressPrefix = [NSString stringWithFormat:@"%@://%@:%@/debugger-proxy", devInfo.scheme, devInfo.ipAddress, port];
if (devInfo.wsURL.length > 0) {
// wsURL has a high priority
addressPrefix = devInfo.wsURL;
Expand Down

0 comments on commit aea12a3

Please sign in to comment.