Skip to content

Commit

Permalink
Don't attempt to reconnect on fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
melonmanchan committed Mar 4, 2016
1 parent 695902c commit 5b557a5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/js/services/peerhandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ peerhandler.factory('peerFactory', function(configFactory, $rootScope, $ionicPop
};

reconnectScope.forceReconnect = function () {
me.reconnect();
if (me.destroyed === false ){
me.reconnect();
}
};

// Array of callback functions to handle data
Expand Down Expand Up @@ -319,6 +321,12 @@ peerhandler.factory('peerFactory', function(configFactory, $rootScope, $ionicPop

var attemptReconnect = function () {

if (me.destroyed === true) {
stopReconnectAttempt({ failed: true });
return;

}

if (me && me.disconnected === true && me.open === false ) {
console.log('attempting to reconnect...');
me.reconnect();
Expand Down Expand Up @@ -471,6 +479,7 @@ peerhandler.factory('peerFactory', function(configFactory, $rootScope, $ionicPop

me.on('close', function() {
console.log('closed Peerjs connection');
reject();
});

me.socket._socket.onopen = function() {
Expand Down

0 comments on commit 5b557a5

Please sign in to comment.