Skip to content

Commit

Permalink
Fixes #112 Duplicate file
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserf committed May 15, 2016
1 parent bba9c7d commit 388e173
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 68 deletions.
53 changes: 0 additions & 53 deletions src/utils/reconnection-notifier.js

This file was deleted.

30 changes: 15 additions & 15 deletions src/utils/resubscribe-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ var ResubscribeNotifier = function( client, resubscribe ) {
this._client = client;
this._resubscribe = resubscribe;

this._isReconnecting = false;
this._connectionStateChangeHandler = this._handleConnectionStateChanges.bind( this );
this._client.on( 'connectionStateChanged', this._connectionStateChangeHandler );
this._isReconnecting = false;
this._connectionStateChangeHandler = this._handleConnectionStateChanges.bind( this );
this._client.on( 'connectionStateChanged', this._connectionStateChangeHandler );
};

/**
Expand All @@ -28,9 +28,9 @@ var ResubscribeNotifier = function( client, resubscribe ) {
* @returns {void}
*/
ResubscribeNotifier.prototype.destroy = function() {
this._client.removeListener( 'connectionStateChanged', this._connectionStateChangeHandler );
this._connectionStateChangeHandler = null;
this._client = null;
this._client.removeListener( 'connectionStateChanged', this._connectionStateChangeHandler );
this._connectionStateChangeHandler = null;
this._client = null;
};

/**
Expand All @@ -39,15 +39,15 @@ ResubscribeNotifier.prototype.destroy = function() {
* @returns {void}
*/
ResubscribeNotifier.prototype._handleConnectionStateChanges = function() {
var state = this._client.getConnectionState();
if( state === C.CONNECTION_STATE.RECONNECTING && this._isReconnecting === false ) {
this._isReconnecting = true;
}
if( state === C.CONNECTION_STATE.OPEN && this._isReconnecting === true ) {
this._isReconnecting = false;
this._resubscribe();
}
var state = this._client.getConnectionState();
if( state === C.CONNECTION_STATE.RECONNECTING && this._isReconnecting === false ) {
this._isReconnecting = true;
}
if( state === C.CONNECTION_STATE.OPEN && this._isReconnecting === true ) {
this._isReconnecting = false;
this._resubscribe();
}
};

module.exports = ResubscribeNotifier;

0 comments on commit 388e173

Please sign in to comment.