@@ -8,6 +8,7 @@ import * as path from "path";
88import * as semver from "semver" ;
99import * as net from "net" ;
1010import Future = require( "fibers/future" ) ;
11+ import * as helpers from "../common/helpers" ;
1112
1213export class UsbLiveSyncService extends usbLivesyncServiceBaseLib . UsbLiveSyncServiceBase implements IUsbLiveSyncService {
1314
@@ -49,7 +50,7 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
4950 this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
5051 let frameworkVersion = this . $projectDataService . getValue ( platformData . frameworkPackageName ) . wait ( ) . version ;
5152 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 ( ) ;
5354 if ( shouldUpdate ) {
5455 this . $platformService . updatePlatforms ( [ this . $devicePlatformsConstants . Android . toLowerCase ( ) ] ) . wait ( ) ;
5556 } else {
@@ -62,19 +63,9 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
6263
6364 let projectFilesPath = path . join ( platformData . appDestinationDirectoryPath , constants . APP_FOLDER_NAME ) ;
6465
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 ) ;
7167
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 ( ) ) ;
7869
7970 let beforeLiveSyncAction = ( device : Mobile . IDevice , deviceAppData : Mobile . IDeviceAppData ) : IFuture < void > => {
8071 let platformSpecificUsbLiveSyncService = this . resolveUsbLiveSyncService ( platform || this . $devicesService . platform , device ) ;
@@ -128,6 +119,8 @@ export class UsbLiveSyncService extends usbLivesyncServiceBaseLib.UsbLiveSyncSer
128119 let mappedFilePath = beforeBatchLiveSyncAction ( filePath ) . wait ( ) ;
129120
130121 if ( this . shouldSynciOSSimulator ( platform ) . wait ( ) ) {
122+ this . $iOSEmulatorServices . transferFiles ( this . $projectData . projectId , [ filePath ] , iOSSimulatorRelativeToProjectBasePathAction ) . wait ( ) ;
123+
131124 let platformSpecificUsbLiveSyncService = < IiOSUsbLiveSyncService > this . resolvePlatformSpecificLiveSyncService ( platform || this . $devicesService . platform , null , platformSpecificLiveSyncServices ) ;
132125 platformSpecificUsbLiveSyncService . sendPageReloadMessageToSimulator ( ) . wait ( ) ;
133126 } else {
@@ -192,7 +185,11 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
192185 constructor ( private _device : Mobile . IDevice ,
193186 private $iOSSocketRequestExecutor : IiOSSocketRequestExecutor ,
194187 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 ) { }
196193
197194 private get device ( ) : Mobile . IiOSDevice {
198195 return < Mobile . IiOSDevice > this . _device ;
@@ -212,11 +209,8 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
212209 }
213210
214211 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 ) ;
220214 }
221215
222216 private sendReloadMessageCore ( socket : net . Socket ) : void {
@@ -226,6 +220,7 @@ export class IOSUsbLiveSyncService implements IiOSUsbLiveSyncService {
226220 payload . writeInt32BE ( length , 0 ) ;
227221 payload . write ( message , 4 , length , "utf16le" ) ;
228222 socket . write ( payload ) ;
223+ socket . destroy ( ) ;
229224 }
230225}
231226$injector . register ( "iosUsbLiveSyncServiceLocator" , { factory : IOSUsbLiveSyncService } ) ;
0 commit comments