@@ -22,13 +22,13 @@ const DEFAULT_LOCAL_HOST_ADDRESS = "127.0.0.1";
22
22
export class AndroidLivesyncTool implements IAndroidLivesyncTool {
23
23
private operationPromises : IDictionary < any > ;
24
24
private socketError : string | Error ;
25
- private socketConnection : IDuplexSocket ;
25
+ private socketConnection : INetSocket ;
26
26
private configuration : IAndroidLivesyncToolConfiguration ;
27
27
private pendingConnectionData : {
28
28
connectionTimer ?: NodeJS . Timer ,
29
29
socketTimer ?: NodeJS . Timer ,
30
30
rejectHandler ?: Function ,
31
- socket ?: IDuplexSocket
31
+ socket ?: INetSocket
32
32
} = null ;
33
33
34
34
constructor ( private $androidProcessService : Mobile . IAndroidProcessService ,
@@ -173,6 +173,7 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
173
173
this . cleanState ( socketUid ) ;
174
174
//call end of the connection (close and error callbacks won't be called - listeners removed)
175
175
socket . end ( ) ;
176
+ socket . destroy ( ) ;
176
177
//reject all pending sync requests and clear timeouts
177
178
this . rejectPendingSyncOperations ( socketUid , error ) ;
178
179
}
@@ -254,7 +255,7 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
254
255
} ) ;
255
256
}
256
257
257
- private createSocket ( port : number ) : IDuplexSocket {
258
+ private createSocket ( port : number ) : INetSocket {
258
259
const socket = new net . Socket ( ) ;
259
260
socket . connect ( port , this . configuration . localHostAddress ) ;
260
261
return socket ;
@@ -280,7 +281,7 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
280
281
}
281
282
}
282
283
283
- private handleConnection ( { socket, data } : { socket : IDuplexSocket , data : NodeBuffer | string } ) {
284
+ private handleConnection ( { socket, data } : { socket : INetSocket , data : NodeBuffer | string } ) {
284
285
this . socketConnection = socket ;
285
286
this . socketConnection . uid = this . generateOperationIdentifier ( ) ;
286
287
@@ -304,15 +305,15 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
304
305
} ) ;
305
306
}
306
307
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 } > {
308
309
return new Promise ( ( resolve , reject ) => {
309
310
let lastKnownError : Error | string ,
310
311
isConnected = false ;
311
312
312
313
const connectionTimer = setTimeout ( ( ) => {
313
314
if ( ! isConnected ) {
314
315
isConnected = true ;
315
- reject ( lastKnownError || { message : "Socket connection timeouted." } ) ;
316
+ reject ( lastKnownError || new Error ( "Socket connection timeouted." ) ) ;
316
317
this . pendingConnectionData = null ;
317
318
}
318
319
} , timeout ) ;
0 commit comments