mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 11:26:25 +00:00
31 lines
713 B
JavaScript
31 lines
713 B
JavaScript
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()
|
|
}
|
|
}
|