do not close socket even when it's not in other swarms

This commit is contained in:
Feross Aboukhadijeh 2017-02-21 01:50:48 -08:00
parent b2c2b8f0d0
commit fe11c695cb

View File

@ -29,15 +29,7 @@ function Swarm (infoHash, server) {
peer_id: peer.peerId
}
self._onAnnounceStopped(params, peer, peer.peerId)
// When a websocket peer is evicted, and it's not in any other swarms, close
// the websocket to conserve server resources.
if (peer.socket && peer.socket.infoHashes.length === 0) {
try {
peer.socket.close()
peer.socket = null
} catch (err) {}
}
peer.socket = null
})
}