Limit number of WebRTC offers to only 5

This commit is contained in:
Feross Aboukhadijeh 2015-05-03 16:53:37 -07:00
parent 1de0983864
commit 9a6e854609
2 changed files with 5 additions and 1 deletions

View File

@ -6,7 +6,7 @@ var extend = require('xtend/mutable')
exports.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes exports.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes
exports.DEFAULT_ANNOUNCE_PEERS = process.browser ? 5 : 50 exports.DEFAULT_ANNOUNCE_PEERS = 50
exports.MAX_ANNOUNCE_PEERS = 82 exports.MAX_ANNOUNCE_PEERS = 82
exports.binaryToHex = function (str) { exports.binaryToHex = function (str) {

View File

@ -59,6 +59,10 @@ WebSocketTracker.prototype.announce = function (opts) {
opts.info_hash = self.client._infoHash.toString('binary') opts.info_hash = self.client._infoHash.toString('binary')
opts.peer_id = self.client._peerId.toString('binary') opts.peer_id = self.client._peerId.toString('binary')
// Limit number of offers to only 5 (temporarily)
// TODO: remove this when we cleanup old RTCPeerConnections cleanly
if (opts.numWant > 5) opts.numWant = 5
self._generateOffers(opts.numWant, function (offers) { self._generateOffers(opts.numWant, function (offers) {
opts.offers = offers opts.offers = offers