mirror of https://github.com/BTCPrivate/copay.git
close socket on disconnect
This commit is contained in:
parent
04080c6ac6
commit
4fff3a9d4d
|
@ -1753,9 +1753,8 @@ Wallet.prototype.disconnect = function() {
|
||||||
self.send(null, {
|
self.send(null, {
|
||||||
type: 'disconnect',
|
type: 'disconnect',
|
||||||
walletId: this.id,
|
walletId: this.id,
|
||||||
}, function() {
|
|
||||||
self.network.cleanUp();
|
|
||||||
});
|
});
|
||||||
|
self.network.cleanUp();
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.getNetwork = function() {
|
Wallet.prototype.getNetwork = function() {
|
||||||
|
|
|
@ -46,25 +46,15 @@ Network.prototype.cleanUp = function() {
|
||||||
this.connections = {};
|
this.connections = {};
|
||||||
this.criticalErr = '';
|
this.criticalErr = '';
|
||||||
this.removeAllListeners();
|
this.removeAllListeners();
|
||||||
|
if (this.socket) {
|
||||||
|
this.socket.disconnect();
|
||||||
|
this.socket = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Network.parent = EventEmitter;
|
Network.parent = EventEmitter;
|
||||||
|
|
||||||
// Array helpers
|
// Array helpers
|
||||||
Network._arrayDiff = function(a, b) {
|
|
||||||
var seen = [];
|
|
||||||
var diff = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < b.length; i++)
|
|
||||||
seen[b[i]] = true;
|
|
||||||
|
|
||||||
for (var j = 0; j < a.length; j++)
|
|
||||||
if (!seen[a[j]])
|
|
||||||
diff.push(a[j]);
|
|
||||||
|
|
||||||
return diff;
|
|
||||||
};
|
|
||||||
|
|
||||||
Network._inArray = function(el, array) {
|
Network._inArray = function(el, array) {
|
||||||
return array.indexOf(el) > -1;
|
return array.indexOf(el) > -1;
|
||||||
};
|
};
|
||||||
|
@ -303,11 +293,6 @@ Network.prototype.start = function(opts, openCallback) {
|
||||||
this.setCopayerId(opts.copayerId);
|
this.setCopayerId(opts.copayerId);
|
||||||
this.maxPeers = opts.maxPeers || this.maxPeers;
|
this.maxPeers = opts.maxPeers || this.maxPeers;
|
||||||
|
|
||||||
if (this.socket) {
|
|
||||||
this.socket.destroy();
|
|
||||||
this.socket.removeAllListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.socket = this.createSocket(this.host, this.port);
|
this.socket = this.createSocket(this.host, this.port);
|
||||||
this._setupConnectionHandlers(openCallback);
|
this._setupConnectionHandlers(openCallback);
|
||||||
this.socket.emit('subscribe', pubkey);
|
this.socket.emit('subscribe', pubkey);
|
||||||
|
|
Loading…
Reference in New Issue