|
@@ -48,8 +48,9 @@ Peer.prototype._startSocket = function() {
|
|
});
|
|
});
|
|
this._socket.on('unavailable', function(peer) {
|
|
this._socket.on('unavailable', function(peer) {
|
|
util.log('Destination peer not available.', peer);
|
|
util.log('Destination peer not available.', peer);
|
|
- if (self.connections[peer])
|
|
|
|
|
|
+ if (self.connections[peer]) {
|
|
self.connections[peer].close();
|
|
self.connections[peer].close();
|
|
|
|
+ }
|
|
});
|
|
});
|
|
this._socket.on('error', function(error) {
|
|
this._socket.on('error', function(error) {
|
|
util.log(error);
|
|
util.log(error);
|
|
@@ -119,10 +120,9 @@ Peer.prototype._processQueue = function() {
|
|
|
|
|
|
|
|
|
|
Peer.prototype._cleanup = function() {
|
|
Peer.prototype._cleanup = function() {
|
|
- for (var peer in this.connections) {
|
|
|
|
- if (this.connections.hasOwnProperty(peer)) {
|
|
|
|
- this.connections[peer].close();
|
|
|
|
- }
|
|
|
|
|
|
+ var peers = Object.keys(this.connections);
|
|
|
|
+ for (var i = 0, ii = peers.length; i < ii; i++) {
|
|
|
|
+ this.connections[peers[i]].close();
|
|
}
|
|
}
|
|
this._socket.close();
|
|
this._socket.close();
|
|
};
|
|
};
|