Skip to content

Commit

Permalink
refs #17661, fix for when options are not passed to socket/Reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
neonstalwart authored and dylans committed Apr 19, 2015
1 parent 5d98b2d commit 5a7969c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions socket/Reconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ define([
// | var socket = dxSocket({url:"/comet"});
// | // add auto-reconnect support
// | socket = reconnect(socket);
options = options || {};

var reconnectTime = options.reconnectTime || 10000;
var backoffRate = options.backoffRate || 2;
var timeout = reconnectTime;
var checkForOpen, newSocket;
options = options || {};

aspect.after(socket, "onclose", function(event){
clearTimeout(checkForOpen);
Expand All @@ -36,12 +39,12 @@ define([
checkForOpen = setTimeout(function(){
//reset the backoff
if(newSocket.readyState < 2){
reconnectTime = options.reconnectTime || 10000;
timeout = reconnectTime;
}
}, 10000);
}, reconnectTime);
}, reconnectTime);
}, timeout);
// backoff each time
reconnectTime *= options.backoffRate || 2;
timeout *= backoffRate;
};
}
if(!socket.reconnect){
Expand Down

0 comments on commit 5a7969c

Please sign in to comment.