From f5d2810c8933d435b7affca2442502d078b26ba4 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 29 Jul 2015 02:12:14 -0700 Subject: [PATCH] Announce to websocket tracker every 30 seconds (for #338) --- lib/client/http-tracker.js | 2 ++ lib/client/tracker.js | 4 +--- lib/client/udp-tracker.js | 2 ++ lib/client/websocket-tracker.js | 2 ++ lib/common.js | 2 -- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/client/http-tracker.js b/lib/client/http-tracker.js index 5777134..b82691f 100644 --- a/lib/client/http-tracker.js +++ b/lib/client/http-tracker.js @@ -34,6 +34,8 @@ function HTTPTracker (client, announceUrl, opts) { } } +HTTPTracker.prototype.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes + HTTPTracker.prototype.announce = function (opts) { var self = this if (self.destroyed) return diff --git a/lib/client/tracker.js b/lib/client/tracker.js index 213f3ce..8d53f1e 100644 --- a/lib/client/tracker.js +++ b/lib/client/tracker.js @@ -3,8 +3,6 @@ module.exports = Tracker var EventEmitter = require('events').EventEmitter var inherits = require('inherits') -var common = require('../common') - inherits(Tracker, EventEmitter) function Tracker (client, announceUrl) { @@ -20,7 +18,7 @@ function Tracker (client, announceUrl) { Tracker.prototype.setInterval = function (intervalMs) { var self = this if (self.interval) return - if (intervalMs == null) intervalMs = common.DEFAULT_ANNOUNCE_INTERVAL + if (intervalMs == null) intervalMs = self.DEFAULT_ANNOUNCE_INTERVAL clearInterval(self.interval) diff --git a/lib/client/udp-tracker.js b/lib/client/udp-tracker.js index 8f66b1e..ead529c 100644 --- a/lib/client/udp-tracker.js +++ b/lib/client/udp-tracker.js @@ -30,6 +30,8 @@ function UDPTracker (client, announceUrl, opts) { self.cleanupFns = [] } +UDPTracker.prototype.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes + UDPTracker.prototype.announce = function (opts) { var self = this if (self.destroyed) return diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index f3c1897..15435dc 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -32,6 +32,8 @@ function WebSocketTracker (client, announceUrl, opts) { self._openSocket() } +WebSocketTracker.prototype.DEFAULT_ANNOUNCE_INTERVAL = 30 * 1000 // 30 seconds + WebSocketTracker.prototype.announce = function (opts) { var self = this if (self.destroyed) return diff --git a/lib/common.js b/lib/common.js index a6f191a..add8784 100644 --- a/lib/common.js +++ b/lib/common.js @@ -4,8 +4,6 @@ var extend = require('xtend/mutable') -exports.DEFAULT_ANNOUNCE_INTERVAL = 30 * 60 * 1000 // 30 minutes - exports.DEFAULT_ANNOUNCE_PEERS = 50 exports.MAX_ANNOUNCE_PEERS = 82