mirror of https://github.com/BTCPrivate/copay.git
rm disconnect message, rename disconnect fn
This commit is contained in:
parent
2809a145e2
commit
6aa959dcf5
|
@ -49,11 +49,7 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
|
||||||
};
|
};
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
var w = $rootScope.wallet;
|
controllerUtils.logout();
|
||||||
if (w) {
|
|
||||||
w.disconnect();
|
|
||||||
controllerUtils.logout();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ng-repeat defined number of times instead of repeating over array?
|
// ng-repeat defined number of times instead of repeating over array?
|
||||||
|
|
|
@ -323,6 +323,7 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
preconditions.checkArgument(ts);
|
preconditions.checkArgument(ts);
|
||||||
preconditions.checkArgument(typeof ts === 'number');
|
preconditions.checkArgument(typeof ts === 'number');
|
||||||
|
|
||||||
|
//console.log('RECV', senderId, data);
|
||||||
|
|
||||||
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
||||||
this.emit('corrupt', senderId);
|
this.emit('corrupt', senderId);
|
||||||
|
@ -358,12 +359,13 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
case 'addressbook':
|
case 'addressbook':
|
||||||
this._onAddressBook(senderId, data);
|
this._onAddressBook(senderId, data);
|
||||||
break;
|
break;
|
||||||
|
// unused messages
|
||||||
case 'disconnect':
|
case 'disconnect':
|
||||||
this._onDisconnect(senderId, data);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('unknown message type received: '+ data.type + ' from: ' + senderId)
|
throw new Error('unknown message type received: '+ data.type + ' from: ' + senderId)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateTimestamp(ts);
|
this.updateTimestamp(ts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -376,12 +378,6 @@ Wallet.prototype._onConnect = function(newCopayerId) {
|
||||||
this.emit('connect', peerID);
|
this.emit('connect', peerID);
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype._onDisconnect = function(peerID) {
|
|
||||||
this.currentDelay = null;
|
|
||||||
this.emit('disconnect', peerID);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype.getNetworkName = function() {
|
Wallet.prototype.getNetworkName = function() {
|
||||||
return this.publicKeyRing.network.name;
|
return this.publicKeyRing.network.name;
|
||||||
};
|
};
|
||||||
|
@ -1746,15 +1742,10 @@ Wallet.prototype.indexDiscovery = function(start, change, copayerIndex, gap, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Wallet.prototype.disconnect = function() {
|
Wallet.prototype.close = function() {
|
||||||
this.log('## DISCONNECTING');
|
this.log('## CLOSING');
|
||||||
this.lock.release();
|
this.lock.release();
|
||||||
var self = this;
|
this.network.cleanUp();
|
||||||
self.send(null, {
|
|
||||||
type: 'disconnect',
|
|
||||||
walletId: this.id,
|
|
||||||
});
|
|
||||||
self.network.cleanUp();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.getNetwork = function() {
|
Wallet.prototype.getNetwork = function() {
|
||||||
|
|
|
@ -220,7 +220,7 @@ Network.prototype._setupConnectionHandlers = function(cb) {
|
||||||
});
|
});
|
||||||
self.socket.on('error', self._onError.bind(self));
|
self.socket.on('error', self._onError.bind(self));
|
||||||
|
|
||||||
self.socket.on('no messages', self.bind(self, 'no messages'));
|
self.socket.on('no messages', self.emit.bind(self, 'no messages'));
|
||||||
|
|
||||||
self.socket.on('connect', function() {
|
self.socket.on('connect', function() {
|
||||||
|
|
||||||
|
@ -348,23 +348,23 @@ Network.prototype.send = function(dest, payload, cb) {
|
||||||
dest = this.getCopayerIds();
|
dest = this.getCopayerIds();
|
||||||
payload.isBroadcast = 1;
|
payload.isBroadcast = 1;
|
||||||
}
|
}
|
||||||
console.log('SEND to: ' + to, payload);
|
|
||||||
|
|
||||||
if (typeof dest === 'string')
|
if (typeof dest === 'string')
|
||||||
dest = [dest];
|
dest = [dest];
|
||||||
|
|
||||||
var l = dest.length;
|
var l = dest.length;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
dest.forEach(function(to) {
|
for(var ii in dest){
|
||||||
if (to === this.copayerId)
|
var to = dest[ii];
|
||||||
|
if (to == this.copayerId)
|
||||||
continue;
|
continue;
|
||||||
|
console.log('SEND to: ' + to, this.copayerId, payload);
|
||||||
|
|
||||||
|
|
||||||
//console.log('\t to ' + to);
|
var message = this.encode(to, payload);
|
||||||
var message = self.encode(to, payload);
|
this.socket.emit('message', message);
|
||||||
|
}
|
||||||
|
|
||||||
self.socket.emit('message', message);
|
|
||||||
});
|
|
||||||
if (typeof cb === 'function') cb();
|
if (typeof cb === 'function') cb();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
root.logout = function() {
|
root.logout = function() {
|
||||||
if ($rootScope.wallet)
|
if ($rootScope.wallet)
|
||||||
$rootScope.wallet.disconnect();
|
$rootScope.wallet.close();
|
||||||
|
|
||||||
Socket.removeAllListeners();
|
Socket.removeAllListeners();
|
||||||
|
|
||||||
|
@ -179,9 +179,6 @@ angular.module('copayApp.services')
|
||||||
}
|
}
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
});
|
});
|
||||||
w.on('disconnect', function(peerID) {
|
|
||||||
$rootScope.$digest();
|
|
||||||
});
|
|
||||||
w.on('close', root.onErrorDigest);
|
w.on('close', root.onErrorDigest);
|
||||||
w.on('locked', root.onErrorDigest.bind(this));
|
w.on('locked', root.onErrorDigest.bind(this));
|
||||||
w.netStart();
|
w.netStart();
|
||||||
|
|
Loading…
Reference in New Issue