From 90260d1d3da2bddf351b4057e8b078e66c25c0ea Mon Sep 17 00:00:00 2001 From: Mostafa Samir Date: Mon, 4 Apr 2016 00:30:44 +0200 Subject: [PATCH 1/2] added 'explicitlyDisconnected' flag to Client object this flag will be set to true when a 'ipc.disconnect' is called on the client to prevent the client from attempting to retry to connect --- dao/client.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dao/client.js b/dao/client.js index f1e0f08..eae834e 100644 --- a/dao/client.js +++ b/dao/client.js @@ -16,7 +16,8 @@ function init(config,log){ connect : connect, emit : emit, log : log, - retriesRemaining:config.maxRetries||0 + retriesRemaining:config.maxRetries||0, + explicitlyDisconnected: false }; new Pubsub(client); @@ -143,7 +144,9 @@ function connect(){ ); if( - client.config.stopRetrying || client.retriesRemaining<1 + client.config.stopRetrying || + client.retriesRemaining<1 || + client.explicitlyDisconnected ){ client.trigger('disconnect'); From f3f7bdbf3f81e124596fa1d584c9036fdc315527 Mon Sep 17 00:00:00 2001 From: Mostafa Samir Date: Mon, 4 Apr 2016 00:32:17 +0200 Subject: [PATCH 2/2] set client's 'explicitlyDisconnected' flag to true when disconnect is called this is instead of using the 'stopRetrying' flag that would affect the retrying policy of other clients --- services/IPC.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/IPC.js b/services/IPC.js index 91f9aed..083866d 100644 --- a/services/IPC.js +++ b/services/IPC.js @@ -92,7 +92,7 @@ function disconnect(id){ return; } - this.of[id].config.stopRetrying=true; + this.of[id].explicitlyDisconnected=true; this.of[id].off('*'); if(this.of[id].socket){