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