simply a little webRTC error handling, add more messages

This commit is contained in:
Matias Alejo Garcia 2014-06-07 19:12:24 -03:00
commit 521dd3efe5
6 changed files with 57 additions and 39 deletions

View file

@ -161,6 +161,7 @@ Wallet.prototype._handleData = function(senderId, data, isInbound) {
Wallet.prototype._handleConnect = function(newCopayerId) {
if (newCopayerId) {
this.log('#### Setting new COPAYER:', newCopayerId);
this.currentDelay = this.reconnectDelay;
this.sendWalletId(newCopayerId);
}
var peerID = this.network.peerFromCopayer(newCopayerId)
@ -232,18 +233,11 @@ Wallet.prototype.netStart = function() {
net.on('connect', self._handleConnect.bind(self));
net.on('disconnect', self._handleDisconnect.bind(self));
net.on('data', self._handleData.bind(self));
net.on('openError', function() {
self.log('[Wallet.js.132:openError:] GOT openError'); //TODO
self.emit('openError');
});
net.on('error', function() {
self.emit('connectionError');
});
net.on('close', function() {
self.emit('close');
});
net.on('serverError', function() {
self.emit('serverError');
net.on('serverError', function(msg) {
self.emit('serverError', msg);
});
var myId = self.getMyCopayerId();
@ -271,9 +265,12 @@ Wallet.prototype.netStart = function() {
Wallet.prototype.scheduleConnect = function() {
var self = this;
self.currentDelay = self.currentDelay || self.reconnectDelay;
if (self.network.isOnline()) {
self.connectToAll();
setTimeout(self.scheduleConnect.bind(self), self.reconnectDelay);
self.currentDelay *=2;
setTimeout(self.scheduleConnect.bind(self), self.currentDelay);
}
}