@@ -22,13 +22,13 @@ const DEFAULT_LOCAL_HOST_ADDRESS = "127.0.0.1";
2222export class AndroidLivesyncTool implements IAndroidLivesyncTool {
2323 private operationPromises : IDictionary < any > ;
2424 private socketError : string | Error ;
25- private socketConnection : IDuplexSocket ;
25+ private socketConnection : INetSocket ;
2626 private configuration : IAndroidLivesyncToolConfiguration ;
2727 private pendingConnectionData : {
2828 connectionTimer ?: NodeJS . Timer ,
2929 socketTimer ?: NodeJS . Timer ,
3030 rejectHandler ?: Function ,
31- socket ?: IDuplexSocket
31+ socket ?: INetSocket
3232 } = null ;
3333
3434 constructor ( private $androidProcessService : Mobile . IAndroidProcessService ,
@@ -173,6 +173,7 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
173173 this . cleanState ( socketUid ) ;
174174 //call end of the connection (close and error callbacks won't be called - listeners removed)
175175 socket . end ( ) ;
176+ socket . destroy ( ) ;
176177 //reject all pending sync requests and clear timeouts
177178 this . rejectPendingSyncOperations ( socketUid , error ) ;
178179 }
@@ -254,7 +255,7 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
254255 } ) ;
255256 }
256257
257- private createSocket ( port : number ) : IDuplexSocket {
258+ private createSocket ( port : number ) : INetSocket {
258259 const socket = new net . Socket ( ) ;
259260 socket . connect ( port , this . configuration . localHostAddress ) ;
260261 return socket ;
@@ -280,7 +281,7 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
280281 }
281282 }
282283
283- private handleConnection ( { socket, data } : { socket : IDuplexSocket , data : NodeBuffer | string } ) {
284+ private handleConnection ( { socket, data } : { socket : INetSocket , data : NodeBuffer | string } ) {
284285 this . socketConnection = socket ;
285286 this . socketConnection . uid = this . generateOperationIdentifier ( ) ;
286287
@@ -304,15 +305,15 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
304305 } ) ;
305306 }
306307
307- private connectEventuallyUntilTimeout ( factory : ( ) => IDuplexSocket , timeout : number ) : Promise < { socket : IDuplexSocket , data : NodeBuffer | string } > {
308+ private connectEventuallyUntilTimeout ( factory : ( ) => INetSocket , timeout : number ) : Promise < { socket : INetSocket , data : NodeBuffer | string } > {
308309 return new Promise ( ( resolve , reject ) => {
309310 let lastKnownError : Error | string ,
310311 isConnected = false ;
311312
312313 const connectionTimer = setTimeout ( ( ) => {
313314 if ( ! isConnected ) {
314315 isConnected = true ;
315- reject ( lastKnownError || { message : "Socket connection timeouted." } ) ;
316+ reject ( lastKnownError || new Error ( "Socket connection timeouted." ) ) ;
316317 this . pendingConnectionData = null ;
317318 }
318319 } , timeout ) ;
0 commit comments