rm variable reconnect time

This commit is contained in:
Matias Alejo Garcia 2014-06-09 19:35:30 -03:00
commit be7e122b0a
4 changed files with 22 additions and 33 deletions

View file

@ -42,26 +42,26 @@ var defaultConfig = {
config: {
'iceServers': [
// Pass in STUN and TURN servers for maximum network compatibility
{
url: 'stun:162.242.219.26'
}, {
url: 'turn:162.242.219.26',
username: 'bitcore',
credential: 'bitcore',
}
// {
// url: 'stun:stun.l.google.com:19302'
// url: 'stun:162.242.219.26'
// }, {
// url: 'stun:stun1.l.google.com:19302'
// }, {
// url: 'stun:stun2.l.google.com:19302'
// }, {
// url: 'stun:stun3.l.google.com:19302'
// }, {
// url: 'stun:stun4.l.google.com:19302'
// }, {
// url: 'stun:stunserver.org'
// url: 'turn:162.242.219.26',
// username: 'bitcore',
// credential: 'bitcore',
// }
{
url: 'stun:stun.l.google.com:19302'
}, {
url: 'stun:stun1.l.google.com:19302'
}, {
url: 'stun:stun2.l.google.com:19302'
}, {
url: 'stun:stun3.l.google.com:19302'
}, {
url: 'stun:stun4.l.google.com:19302'
}, {
url: 'stun:stunserver.org'
}
// // Options fot TURN servers with p2p communications are not possible.
// {
// url: 'turn:numb.viagenie.ca',
@ -86,7 +86,7 @@ var defaultConfig = {
totalCopayers: 3,
spendUnconfirmed: 1,
verbose: 1,
reconnectDelay: 500,
reconnectDelay: 5000,
},
// blockchain service API config

View file

@ -164,7 +164,6 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
Wallet.prototype._handleConnect = function(newCopayerId) {
if (newCopayerId) {
this.log('#### Setting new COPAYER:', newCopayerId);
this.currentDelay = null;
this.sendWalletId(newCopayerId);
}
var peerID = this.network.peerFromCopayer(newCopayerId)
@ -276,8 +275,7 @@ Wallet.prototype.scheduleConnect = function() {
var self = this;
if (self.network.isOnline()) {
self.connectToAll();
self.currentDelay = self.currentDelay*2 || self.reconnectDelay;
setTimeout(self.scheduleConnect.bind(self), self.currentDelay);
setTimeout(self.scheduleConnect.bind(self), self.reconnectDelay);
}
}

View file

@ -126,6 +126,7 @@ Network.prototype._onClose = function(peerID) {
Network.prototype.connectToCopayers = function(copayerIds) {
var self = this;
var arrayDiff= Network._arrayDiff(copayerIds, this.connectedCopayers());
console.log('[WebRTC.js.128:arrayDiff:]',arrayDiff); //TODO
arrayDiff.forEach(function(copayerId) {
if (this.allowedCopayerIds && !this.allowedCopayerIds[copayerId]) {

View file

@ -238,23 +238,13 @@ describe('Wallet model', function() {
throw ();
});
it('call reconnect after interval', function(done) {
it.only('call reconnect after interval', function(done) {
var w = createW2();
var testTime = 1000;
var callCount = 0;
var cT = w.reconnectDelay;
var t = 0;
do {
callCount++;
t += cT;
cT *= 2;
} while (t < testTime);
var spy = sinon.spy(w, 'scheduleConnect');
w.netStart();
setTimeout(function() {
sinon.assert.callCount(spy, callCount);
sinon.assert.callCount(spy, 10);
done();
}, testTime);
});