forked from webtorrent/bittorrent-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracker.js
More file actions
30 lines (23 loc) · 713 Bytes
/
tracker.js
File metadata and controls
30 lines (23 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module.exports = Tracker
var EventEmitter = require('events').EventEmitter
var inherits = require('inherits')
inherits(Tracker, EventEmitter)
function Tracker (client, announceUrl) {
var self = this
EventEmitter.call(self)
self.client = client
self.announceUrl = announceUrl
self.interval = null
self.destroyed = false
}
Tracker.prototype.setInterval = function (intervalMs) {
var self = this
if (intervalMs == null) intervalMs = self.DEFAULT_ANNOUNCE_INTERVAL
clearInterval(self.interval)
if (intervalMs) {
self.interval = setInterval(function () {
self.announce(self.client._defaultAnnounceOpts())
}, intervalMs)
if (self.interval.unref) self.interval.unref()
}
}