mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 03:16:24 +00:00
32 lines
736 B
JavaScript
32 lines
736 B
JavaScript
module.exports = Tracker
|
|
|
|
var EventEmitter = require('events').EventEmitter
|
|
var inherits = require('inherits')
|
|
|
|
var common = require('../common')
|
|
|
|
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 (self.interval) return
|
|
if (intervalMs == null) intervalMs = common.DEFAULT_ANNOUNCE_INTERVAL
|
|
|
|
clearInterval(self.interval)
|
|
|
|
if (intervalMs) {
|
|
var update = self.announce.bind(self, self.client._defaultAnnounceOpts())
|
|
self.interval = setInterval(update, intervalMs)
|
|
}
|
|
}
|