@@ -48,24 +48,19 @@ export class IOSSocketRequestExecutor implements IiOSSocketRequestExecutor {
48
48
}
49
49
}
50
50
51
- public async executeLaunchRequest ( deviceIdentifier : string , timeout : number , readyForAttachTimeout : number , projectId : string , shouldBreak ?: boolean ) : Promise < void > {
51
+ public async executeLaunchRequest ( deviceIdentifier : string , timeout : number , readyForAttachTimeout : number , projectId : string , debugOptions : IDebugOptions ) : Promise < void > {
52
52
try {
53
- const appLaunchingSocket = await this . $iOSNotificationService . postNotification ( deviceIdentifier , this . $iOSNotification . getAppLaunching ( projectId ) , constants . IOS_OBSERVE_NOTIFICATION_COMMAND_TYPE ) ;
54
- await this . $iOSNotificationService . awaitNotification ( deviceIdentifier , + appLaunchingSocket , timeout ) ;
53
+ if ( ! debugOptions . skipHandshake ) {
54
+ await this . executeHandshake ( deviceIdentifier , projectId , timeout ) ;
55
+ }
55
56
56
- if ( shouldBreak ) {
57
+ if ( debugOptions . debugBrk ) {
57
58
await this . $iOSNotificationService . postNotification ( deviceIdentifier , this . $iOSNotification . getWaitForDebug ( projectId ) ) ;
58
59
}
59
60
60
- // We need to send the ObserveNotification ReadyForAttach before we post the AttachRequest.
61
- const readyForAttachSocket = await this . $iOSNotificationService . postNotification ( deviceIdentifier , this . $iOSNotification . getReadyForAttach ( projectId ) , constants . IOS_OBSERVE_NOTIFICATION_COMMAND_TYPE ) ;
62
- const readyForAttachPromise = this . $iOSNotificationService . awaitNotification ( deviceIdentifier , + readyForAttachSocket , readyForAttachTimeout ) ;
63
-
64
- await this . $iOSNotificationService . postNotification ( deviceIdentifier , this . $iOSNotification . getAttachRequest ( projectId , deviceIdentifier ) ) ;
65
- await readyForAttachPromise ;
61
+ await this . executeAttachAvailable ( deviceIdentifier , projectId , readyForAttachTimeout ) ;
66
62
} catch ( e ) {
67
- this . $logger . trace ( "Launch request error:" ) ;
68
- this . $logger . trace ( e ) ;
63
+ this . $logger . trace ( "Launch request error: " , e ) ;
69
64
this . $errors . failWithoutHelp ( "Error while waiting for response from NativeScript runtime." ) ;
70
65
}
71
66
}
@@ -79,9 +74,18 @@ export class IOSSocketRequestExecutor implements IiOSSocketRequestExecutor {
79
74
await this . $iOSNotificationService . postNotification ( deviceIdentifier , this . $iOSNotification . getAttachRequest ( projectId , deviceIdentifier ) ) ;
80
75
await readyForAttachPromise ;
81
76
} catch ( e ) {
77
+ this . $logger . trace ( "Attach available error: " , e ) ;
82
78
this . $errors . failWithoutHelp ( `The application ${ projectId } timed out when performing the socket handshake.` ) ;
83
79
}
84
80
}
81
+
82
+ private async executeHandshake ( deviceIdentifier : string , projectId : string , timeout : number ) : Promise < void > {
83
+ // This notification will be send only once by the runtime during application start.
84
+ // In case app is already running, we'll fail here as we'll not receive it.
85
+ const appLaunchingNotification = this . $iOSNotification . getAppLaunching ( projectId ) ;
86
+ const appLaunchingSocket = await this . $iOSNotificationService . postNotification ( deviceIdentifier , appLaunchingNotification , constants . IOS_OBSERVE_NOTIFICATION_COMMAND_TYPE ) ;
87
+ await this . $iOSNotificationService . awaitNotification ( deviceIdentifier , + appLaunchingSocket , timeout ) ;
88
+ }
85
89
}
86
90
87
91
$injector . register ( "iOSSocketRequestExecutor" , IOSSocketRequestExecutor ) ;
0 commit comments