bittorrent-tracker/lib/client/tracker.js
Cas e6d3189edf
feat: esm (#431)
BREAKING CHANGE: ESM only

* feat: esm

* fix: linter oops
2022-12-05 23:06:54 +01:00

29 lines
609 B
JavaScript

import EventEmitter from '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()
}
}
}
export default Tracker