@@ -66,7 +66,7 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
66
66
67
67
let projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ;
68
68
69
- let notInstalledAppOnDeviceAction = ( device : Mobile . IDevice ) : IFuture < void > => this . $platformService . deployOnDevice ( platform ) ;
69
+ let notInstalledAppOnDeviceAction = ( device : Mobile . IDevice ) : IFuture < void > => this . $platformService . installOnDevice ( platform ) ;
70
70
71
71
let notRunningiOSSimulatorAction = ( ) : IFuture < void > => this . $platformService . deployOnEmulator ( this . $devicePlatformsConstants . iOS . toLowerCase ( ) ) ;
72
72
@@ -117,29 +117,29 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
117
117
let canExecuteFastLiveSync = ( filePath : string ) => _ . contains ( fastLivesyncFileExtensions , path . extname ( filePath ) ) ;
118
118
119
119
let fastLiveSync = ( filePath : string ) => {
120
- return ( ( ) => {
121
- this . $platformService . preparePlatform ( platform ) . wait ( ) ;
122
- let mappedFilePath = beforeBatchLiveSyncAction ( filePath ) . wait ( ) ;
123
-
124
- if ( this . shouldSynciOSSimulator ( platform ) . wait ( ) ) {
125
- this . $iOSEmulatorServices . transferFiles ( this . $projectData . projectId , [ filePath ] , iOSSimulatorRelativeToProjectBasePathAction ) . wait ( ) ;
126
-
127
- let platformSpecificUsbLiveSyncService = < IiOSUsbLiveSyncService > this . resolvePlatformSpecificLiveSyncService ( platform || this . $devicesService . platform , null , platformSpecificLiveSyncServices ) ;
128
- platformSpecificUsbLiveSyncService . sendPageReloadMessageToSimulator ( ) . wait ( ) ;
129
- } else {
130
- let deviceAppData = this . $deviceAppDataFactory . create ( this . $projectData . projectId , this . $mobileHelper . normalizePlatformName ( platform ) ) ;
131
- let localToDevicePaths = this . createLocalToDevicePaths ( platform , this . $projectData . projectId , localProjectRootPath || projectFilesPath , [ mappedFilePath ] ) ;
132
-
133
- let devices = this . $devicesService . getDeviceInstances ( ) ;
134
- _ . each ( devices , ( device : Mobile . IDevice ) => {
135
- this . transferFiles ( device , deviceAppData , localToDevicePaths , projectFilesPath , true ) . wait ( ) ;
136
- let platformSpecificUsbLiveSyncService = this . resolvePlatformSpecificLiveSyncService ( platform || this . $devicesService . platform , device , platformSpecificLiveSyncServices ) ;
137
- return platformSpecificUsbLiveSyncService . sendPageReloadMessageToDevice ( deviceAppData ) . wait ( ) ;
138
- } ) ;
139
-
140
- this . $dispatcher . dispatch ( ( ) => Future . fromResult ( ) ) ;
141
- }
142
- } ) . future < void > ( ) ( ) ;
120
+ this . $dispatcher . dispatch ( ( ) => {
121
+ return ( ( ) => {
122
+ this . $platformService . preparePlatform ( platform ) . wait ( ) ;
123
+ let mappedFilePath = beforeBatchLiveSyncAction ( filePath ) . wait ( ) ;
124
+
125
+ if ( this . shouldSynciOSSimulator ( platform ) . wait ( ) ) {
126
+ this . $iOSEmulatorServices . transferFiles ( this . $projectData . projectId , [ filePath ] , iOSSimulatorRelativeToProjectBasePathAction ) . wait ( ) ;
127
+
128
+ let platformSpecificUsbLiveSyncService = < IiOSUsbLiveSyncService > this . resolvePlatformSpecificLiveSyncService ( platform || this . $devicesService . platform , null , platformSpecificLiveSyncServices ) ;
129
+ platformSpecificUsbLiveSyncService . sendPageReloadMessageToSimulator ( ) . wait ( ) ;
130
+ } else {
131
+ let deviceAppData = this . $deviceAppDataFactory . create ( this . $projectData . projectId , this . $mobileHelper . normalizePlatformName ( platform ) ) ;
132
+ let localToDevicePaths = this . createLocalToDevicePaths ( platform , this . $projectData . projectId , localProjectRootPath || projectFilesPath , [ mappedFilePath ] ) ;
133
+
134
+ let devices = this . $devicesService . getDeviceInstances ( ) ;
135
+ _ . each ( devices , ( device : Mobile . IDevice ) => {
136
+ this . transferFiles ( device , deviceAppData , localToDevicePaths , projectFilesPath , true ) . wait ( ) ;
137
+ let platformSpecificUsbLiveSyncService = this . resolvePlatformSpecificLiveSyncService ( platform || this . $devicesService . platform , device , platformSpecificLiveSyncServices ) ;
138
+ return platformSpecificUsbLiveSyncService . sendPageReloadMessageToDevice ( deviceAppData ) . wait ( ) ;
139
+ } ) ;
140
+ }
141
+ } ) . future < void > ( ) ( )
142
+ } ) ;
143
143
} ;
144
144
145
145
let liveSyncData = {
@@ -207,24 +207,32 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
207
207
let timeout = 9000 ;
208
208
this . $iOSSocketRequestExecutor . executeAttachRequest ( this . device , timeout ) . wait ( ) ;
209
209
let socket = this . device . connectToPort ( IOSUsbLiveSyncService . BACKEND_PORT ) ;
210
- this . sendReloadMessageCore ( socket ) ;
210
+ this . sendReloadMessage ( socket ) ;
211
211
} ) . future < void > ( ) ( ) ;
212
212
}
213
213
214
214
public sendPageReloadMessageToSimulator ( ) : IFuture < void > {
215
- helpers . connectEventually ( ( ) => net . connect ( IOSUsbLiveSyncService . BACKEND_PORT ) , ( socket : net . Socket ) => this . sendReloadMessageCore ( socket ) ) ;
215
+ helpers . connectEventually ( ( ) => net . connect ( IOSUsbLiveSyncService . BACKEND_PORT ) , ( socket : net . Socket ) => this . sendReloadMessage ( socket ) ) ;
216
216
return this . $iOSEmulatorServices . postDarwinNotification ( this . $iOSNotification . attachRequest ) ;
217
217
}
218
218
219
+ private sendReloadMessage ( socket : net . Socket ) : void {
220
+ try {
221
+ this . sendReloadMessageCore ( socket ) ;
222
+ } finally {
223
+ socket . destroy ( ) ;
224
+ }
225
+ }
226
+
219
227
private sendReloadMessageCore ( socket : net . Socket ) : void {
220
228
let message = `{ "method":"Page.reload","params":{"ignoreCache":false},"id":${ ++ currentPageReloadId } }` ;
221
229
let length = Buffer . byteLength ( message , "utf16le" ) ;
222
230
let payload = new Buffer ( length + 4 ) ;
223
231
payload . writeInt32BE ( length , 0 ) ;
224
232
payload . write ( message , 4 , length , "utf16le" ) ;
225
233
socket . write ( payload ) ;
226
- socket . destroy ( ) ;
227
234
}
235
+
228
236
}
229
237
$injector . register ( "iosUsbLiveSyncServiceLocator" , { factory : IOSUsbLiveSyncService } ) ;
230
238
0 commit comments