mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-09 15:51:35 +00:00
29 lines
616 B
JavaScript
29 lines
616 B
JavaScript
const EventEmitter = require('events')
|
|
|
|
class Tracker extends EventEmitter {
|
|
constructor (client, announceUrl) {
|
|
super()
|
|
|
|
this.client = client
|
|
this.announceUrl = announceUrl
|
|
|
|
this.interval = null
|
|
this.destroyed = false
|
|
}
|
|
|
|
setInterval (intervalMs) {
|
|
if (intervalMs == null) intervalMs = this.DEFAULT_ANNOUNCE_INTERVAL
|
|
|
|
clearInterval(this.interval)
|
|
|
|
if (intervalMs) {
|
|
this.interval = setInterval(() => {
|
|
this.announce(this.client._defaultAnnounceOpts())
|
|
}, intervalMs)
|
|
if (this.interval.unref) this.interval.unref()
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Tracker
|