@@ -8,6 +8,7 @@ import * as path from "path";
8
8
import * as semver from "semver" ;
9
9
import * as net from "net" ;
10
10
import Future = require( "fibers/future" ) ;
11
+ import * as helpers from "../common/helpers" ;
11
12
12
13
export class UsbLiveSyncService extends usbLivesyncServiceBaseLib . UsbLiveSyncServiceBase implements IUsbLiveSyncService {
13
14
@@ -49,7 +50,7 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
49
50
this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
50
51
let frameworkVersion = this . $projectDataService . getValue ( platformData . frameworkPackageName ) . wait ( ) . version ;
51
52
if ( semver . lt ( frameworkVersion , "1.2.1" ) ) {
52
- let shouldUpdate = this . $prompter . confirm ( "You need Android Runtime 1.2.1 or later for LiveSync to work properly. Do you want to update your runtime now?" ) . wait ( ) ;
53
+ let shouldUpdate = this . $prompter . confirm ( " You need Android Runtime 1.2.1 or later for LiveSync to work properly. Do you want to update your runtime now?" ) . wait ( ) ;
53
54
if ( shouldUpdate ) {
54
55
this . $platformService . updatePlatforms ( [ this . $devicePlatformsConstants . Android . toLowerCase ( ) ] ) . wait ( ) ;
55
56
} else {
@@ -62,19 +63,9 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
62
63
63
64
let projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ;
64
65
65
- let notInstalledAppOnDeviceAction = ( device : Mobile . IDevice ) : IFuture < boolean > => {
66
- return ( ( ) => {
67
- this . $platformService . deployOnDevice ( platform ) . wait ( ) ;
68
- return false ;
69
- } ) . future < boolean > ( ) ( ) ;
70
- } ;
66
+ let notInstalledAppOnDeviceAction = ( device : Mobile . IDevice ) : IFuture < void > => this . $platformService . deployOnDevice ( platform ) ;
71
67
72
- let notRunningiOSSimulatorAction = ( ) : IFuture < boolean > => {
73
- return ( ( ) => {
74
- this . $platformService . deployOnEmulator ( this . $devicePlatformsConstants . iOS . toLowerCase ( ) ) . wait ( ) ;
75
- return false ;
76
- } ) . future < boolean > ( ) ( ) ;
77
- } ;
68
+ let notRunningiOSSimulatorAction = ( ) : IFuture < void > => this . $platformService . deployOnEmulator ( this . $devicePlatformsConstants . iOS . toLowerCase ( ) ) ;
78
69
79
70
let beforeLiveSyncAction = ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > => {
80
71
let platformSpecificUsbLiveSyncService = this . resolveUsbLiveSyncService ( platform || this . $devicesService . platform , device ) ;
@@ -128,6 +119,8 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
128
119
let mappedFilePath = beforeBatchLiveSyncAction ( filePath ) . wait ( ) ;
129
120
130
121
if ( this . shouldSynciOSSimulator ( platform ) . wait ( ) ) {
122
+ this . $iOSEmulatorServices . transferFiles ( this . $projectData . projectId , [ filePath ] , iOSSimulatorRelativeToProjectBasePathAction ) . wait ( ) ;
123
+
131
124
let platformSpecificUsbLiveSyncService = < IiOSUsbLiveSyncService > this . resolvePlatformSpecificLiveSyncService ( platform || this . $devicesService . platform , null , platformSpecificLiveSyncServices ) ;
132
125
platformSpecificUsbLiveSyncService . sendPageReloadMessageToSimulator ( ) . wait ( ) ;
133
126
} else {
@@ -192,7 +185,11 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
192
185
constructor ( private _device : Mobile . IDevice ,
193
186
private $iOSSocketRequestExecutor : IiOSSocketRequestExecutor ,
194
187
private $iOSNotification : IiOSNotification ,
195
- private $iOSEmulatorServices : Mobile . IiOSSimulatorService ) { }
188
+ private $iOSEmulatorServices : Mobile . IiOSSimulatorService ,
189
+ private $injector : IInjector ,
190
+ private $iOSNotificationService : IiOSNotificationService ,
191
+ private $errors : IErrors ,
192
+ private $projectData : IProjectData ) { }
196
193
197
194
private get device ( ) : Mobile . IiOSDevice {
198
195
return < Mobile . IiOSDevice > this . _device ;
@@ -212,11 +209,8 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
212
209
}
213
210
214
211
public sendPageReloadMessageToSimulator ( ) : IFuture < void > {
215
- return ( ( ) => {
216
- this . $iOSEmulatorServices . postDarwinNotification ( this . $iOSNotification . attachRequest ) . wait ( ) ;
217
- let socket = net . connect ( IOSUsbLiveSyncService . BACKEND_PORT ) ;
218
- this . sendReloadMessageCore ( socket ) ;
219
- } ) . future < void > ( ) ( ) ;
212
+ helpers . connectEventually ( ( ) => net . connect ( IOSUsbLiveSyncService . BACKEND_PORT ) , ( socket : net . Socket ) => this . sendReloadMessageCore ( socket ) ) ;
213
+ return this . $iOSEmulatorServices . postDarwinNotification ( this . $iOSNotification . attachRequest ) ;
220
214
}
221
215
222
216
private sendReloadMessageCore ( socket : net . Socket ) : void {
@@ -226,6 +220,7 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
226
220
payload . writeInt32BE ( length , 0 ) ;
227
221
payload . write ( message , 4 , length , "utf16le" ) ;
228
222
socket . write ( payload ) ;
223
+ socket . destroy ( ) ;
229
224
}
230
225
}
231
226
$injector . register ( "iosUsbLiveSyncServiceLocator" , { factory : IOSUsbLiveSyncService } ) ;
0 commit comments