|
@@ -342,11 +342,12 @@ Peer.prototype.destroy = function() {
|
|
|
|
|
|
/** Disconnects every connection on this peer. */
|
|
|
Peer.prototype._cleanup = function() {
|
|
|
- var peers = Object.keys(this.connections);
|
|
|
- for (var i = 0, ii = peers.length; i < ii; i++) {
|
|
|
- this._cleanupPeer(peers[i]);
|
|
|
+ if (this.connections) {
|
|
|
+ var peers = Object.keys(this.connections);
|
|
|
+ for (var i = 0, ii = peers.length; i < ii; i++) {
|
|
|
+ this._cleanupPeer(peers[i]);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
this.emit('close');
|
|
|
}
|
|
|
|