Skip to content

Commit f8503f6

Browse files
committed
Fix PR comments
1 parent cfc2573 commit f8503f6

10 files changed

+30
-26
lines changed

lib/declarations.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ interface ISocketProxyFactory extends NodeJS.EventEmitter {
645645

646646
interface IiOSNotification {
647647
getWaitForDebug(projectId: string): string;
648-
getAttachRequest(projectId: string): string;
648+
getAttachRequest(projectId: string, deviceId: string): string;
649649
getAppLaunching(projectId: string): string;
650650
getReadyForAttach(projectId: string): string;
651651
getAttachAvailabilityQuery(projectId: string): string;

lib/definitions/ios-log-parser-service.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ interface IIOSLogParserService extends NodeJS.EventEmitter {
33
* Starts looking for debugger port. Attaches on device logs and processes them. In case when port is found, DEBUGGER_PORT_FOUND event is emitted.
44
* @param {Mobile.IDevice} device - Describes the device which logs will be processed.
55
*/
6-
startLookingForDebuggerPort(device: Mobile.IDevice): void;
6+
startParsingLog(device: Mobile.IDevice): void;
77
}

lib/device-sockets/ios/notification.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
export class IOSNotification implements IiOSNotification {
1+
import { EventEmitter } from "events";
2+
import { ATTACH_REQUEST_EVENT_NAME } from "../../common/constants";
3+
4+
export class IOSNotification extends EventEmitter implements IiOSNotification {
25
private static WAIT_FOR_DEBUG_NOTIFICATION_NAME = "WaitForDebugger";
36
private static ATTACH_REQUEST_NOTIFICATION_NAME = "AttachRequest";
47
private static APP_LAUNCHING_NOTIFICATION_NAME = "AppLaunching";
@@ -11,8 +14,9 @@ export class IOSNotification implements IiOSNotification {
1114
return this.formatNotification(IOSNotification.WAIT_FOR_DEBUG_NOTIFICATION_NAME, projectId);
1215
}
1316

14-
public getAttachRequest(projectId: string): string {
15-
return this.formatNotification(IOSNotification.ATTACH_REQUEST_NOTIFICATION_NAME, projectId);
17+
public getAttachRequest(appId: string, deviceId: string): string {
18+
this.emit(ATTACH_REQUEST_EVENT_NAME, { deviceId, appId });
19+
return this.formatNotification(IOSNotification.ATTACH_REQUEST_NOTIFICATION_NAME, appId);
1620
}
1721

1822
public getAppLaunching(projectId: string): string {

lib/device-sockets/ios/socket-request-executor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class IOSSocketRequestExecutor implements IiOSSocketRequestExecutor {
6161
const readyForAttachSocket = await this.$iOSNotificationService.postNotification(deviceIdentifier, this.$iOSNotification.getReadyForAttach(projectId), constants.IOS_OBSERVE_NOTIFICATION_COMMAND_TYPE);
6262
const readyForAttachPromise = this.$iOSNotificationService.awaitNotification(deviceIdentifier, +readyForAttachSocket, readyForAttachTimeout);
6363

64-
await this.$iOSNotificationService.postNotification(deviceIdentifier, this.$iOSNotification.getAttachRequest(projectId));
64+
await this.$iOSNotificationService.postNotification(deviceIdentifier, this.$iOSNotification.getAttachRequest(projectId, deviceIdentifier));
6565
await readyForAttachPromise;
6666
} catch (e) {
6767
this.$logger.trace("Launch request error:");
@@ -76,7 +76,7 @@ export class IOSSocketRequestExecutor implements IiOSSocketRequestExecutor {
7676
// before we send the PostNotification.
7777
const readyForAttachSocket = await this.$iOSNotificationService.postNotification(deviceIdentifier, this.$iOSNotification.getReadyForAttach(projectId), constants.IOS_OBSERVE_NOTIFICATION_COMMAND_TYPE);
7878
const readyForAttachPromise = this.$iOSNotificationService.awaitNotification(deviceIdentifier, +readyForAttachSocket, timeout);
79-
await this.$iOSNotificationService.postNotification(deviceIdentifier, this.$iOSNotification.getAttachRequest(projectId));
79+
await this.$iOSNotificationService.postNotification(deviceIdentifier, this.$iOSNotification.getAttachRequest(projectId, deviceIdentifier));
8080
await readyForAttachPromise;
8181
} catch (e) {
8282
this.$errors.failWithoutHelp(`The application ${projectId} timed out when performing the socket handshake.`);

lib/services/ios-debug-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
128128
private async emulatorStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
129129
const result = await this.wireDebuggerClient(debugData, debugOptions);
130130

131-
const attachRequestMessage = this.$iOSNotification.getAttachRequest(debugData.applicationIdentifier);
131+
const attachRequestMessage = this.$iOSNotification.getAttachRequest(debugData.applicationIdentifier, debugData.deviceIdentifier);
132132

133133
const iOSEmulatorService = <Mobile.IiOSSimulatorService>this.$iOSEmulatorServices;
134134
await iOSEmulatorService.postDarwinNotification(attachRequestMessage, debugData.deviceIdentifier);

lib/services/ios-debugger-port-service.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { DEBUGGER_PORT_FOUND_EVENT_NAME, STARTING_IOS_APPLICATION_EVENT_NAME } from "../common/constants";
1+
import { DEBUGGER_PORT_FOUND_EVENT_NAME, ATTACH_REQUEST_EVENT_NAME } from "../common/constants";
22
import { cache } from "../common/decorators";
33
import * as semver from "semver";
44

55
export class IOSDebuggerPortService implements IIOSDebuggerPortService {
66
private mapDebuggerPortData: IDictionary<IIOSDebuggerPortStoredData> = {};
77
private static DEFAULT_PORT = 18181;
8-
private static MIN_REQUIRED_FRAMEWORK_VERSION = "4.0.0";
8+
private static MIN_REQUIRED_FRAMEWORK_VERSION = "4.0.1";
99

1010
constructor(private $iOSLogParserService: IIOSLogParserService,
1111
private $iOSProjectService: IPlatformProjectService,
@@ -40,14 +40,14 @@ export class IOSDebuggerPortService implements IIOSDebuggerPortService {
4040
}
4141

4242
this.attachToDebuggerPortFoundEventCore();
43-
this.attachToStartingApplicationEvent(device);
43+
this.attachToAttachRequestEvent(device);
4444

45-
this.$iOSLogParserService.startLookingForDebuggerPort(device);
45+
this.$iOSLogParserService.startParsingLog(device);
4646
}
4747

4848
private canStartLookingForDebuggerPort(): boolean {
4949
const frameworkVersion = this.$iOSProjectService.getFrameworkVersion(this.$projectData);
50-
return semver.gte(frameworkVersion, IOSDebuggerPortService.MIN_REQUIRED_FRAMEWORK_VERSION);
50+
return semver.gt(frameworkVersion, IOSDebuggerPortService.MIN_REQUIRED_FRAMEWORK_VERSION);
5151
}
5252

5353
@cache()
@@ -60,13 +60,13 @@ export class IOSDebuggerPortService implements IIOSDebuggerPortService {
6060
}
6161

6262
@cache()
63-
private attachToStartingApplicationEvent(device: Mobile.IDevice): void {
64-
device.applicationManager.on(STARTING_IOS_APPLICATION_EVENT_NAME, (data: IIOSDebuggerPortData) => {
65-
this.$logger.trace(STARTING_IOS_APPLICATION_EVENT_NAME, data);
63+
private attachToAttachRequestEvent(device: Mobile.IDevice): void {
64+
device.applicationManager.on(ATTACH_REQUEST_EVENT_NAME, (data: IIOSDebuggerPortData) => {
65+
this.$logger.trace(ATTACH_REQUEST_EVENT_NAME, data);
6666
const timer = setTimeout(() => {
6767
this.clearTimeout(data);
6868
if (!this.getPortByKey(`${data.deviceId}${data.appId}`)) {
69-
this.$logger.warn("NativeScript debugger was not able to get inspector socket port.");
69+
this.$logger.warn(`NativeScript debugger was not able to get inspector socket port on device ${data.deviceId} for application ${data.appId}.`);
7070
}
7171
}, 5000);
7272

lib/services/ios-log-parser-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ export class IOSLogParserService extends EventEmitter implements IIOSLogParserSe
1313
super();
1414
}
1515

16-
public startLookingForDebuggerPort(device: Mobile.IDevice): void {
16+
public startParsingLog(device: Mobile.IDevice): void {
1717
this.$deviceLogProvider.setProjectNameForDevice(device.deviceInfo.identifier, this.$projectData.projectName);
1818

19-
this.startLookingForDebuggerPortCore(device);
19+
this.startParsingLogCore(device);
2020
this.startLogProcess(device);
2121
}
2222

2323
@cache()
24-
private startLookingForDebuggerPortCore(device: Mobile.IDevice): void {
24+
private startParsingLogCore(device: Mobile.IDevice): void {
2525
const logProvider = device.isEmulator ? this.$iOSSimulatorLogProvider : this.$iosDeviceOperations;
2626
logProvider.on(DEVICE_LOG_EVENT_NAME, (response: IOSDeviceLib.IDeviceLogData) => this.processDeviceLogResponse(response));
2727
}

lib/services/livesync/ios-device-livesync-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
2929
}
3030

3131
if (this.device.isEmulator) {
32-
await this.$iOSEmulatorServices.postDarwinNotification(this.$iOSNotification.getAttachRequest(appId), this.device.deviceInfo.identifier);
32+
await this.$iOSEmulatorServices.postDarwinNotification(this.$iOSNotification.getAttachRequest(appId, this.device.deviceInfo.identifier), this.device.deviceInfo.identifier);
3333
const port = await this.$iOSDebuggerPortService.getPort({ deviceId: this.device.deviceInfo.identifier, appId });
3434
this.socket = await this.$iOSEmulatorServices.connectToPort({ port });
3535
if (!this.socket) {

test/services/ios-log-parser-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe("iOSLogParserService", () => {
8282
const emittedMessagesCount = 1;
8383
const promise = attachOnDebuggerFoundEvent(emittedMessagesCount);
8484

85-
iOSLogParserService.startLookingForDebuggerPort(device);
85+
iOSLogParserService.startParsingLog(device);
8686
emitDeviceLog("test message");
8787
emitDeviceLog(getDebuggerPortMessage(18181));
8888

@@ -95,7 +95,7 @@ describe("iOSLogParserService", () => {
9595
const emittedMessagesCount = 5;
9696
const promise = attachOnDebuggerFoundEvent(emittedMessagesCount);
9797

98-
iOSLogParserService.startLookingForDebuggerPort(device);
98+
iOSLogParserService.startParsingLog(device);
9999
emitDeviceLog(getDebuggerPortMessage(18181));
100100
emitDeviceLog(getDebuggerPortMessage(18181));
101101
emitDeviceLog(getDebuggerPortMessage(18181));
@@ -115,7 +115,7 @@ describe("iOSLogParserService", () => {
115115
const emittedMessagesCount = 5;
116116
const promise = attachOnDebuggerFoundEvent(emittedMessagesCount);
117117

118-
iOSLogParserService.startLookingForDebuggerPort(device);
118+
iOSLogParserService.startParsingLog(device);
119119
emitDeviceLog(getDebuggerPortMessage(45898));
120120
emitDeviceLog(getDebuggerPortMessage(1809));
121121
emitDeviceLog(getDebuggerPortMessage(65072));
@@ -136,7 +136,7 @@ describe("iOSLogParserService", () => {
136136

137137
iOSLogParserService.on(DEBUGGER_PORT_FOUND_EVENT_NAME, (data: IIOSDebuggerPortData) => isDebuggedPortFound = true);
138138

139-
iOSLogParserService.startLookingForDebuggerPort(device);
139+
iOSLogParserService.startParsingLog(device);
140140
emitDeviceLog("some test message");
141141
emitDeviceLog("another test message");
142142

0 commit comments

Comments
 (0)