mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-08 07:11:35 +00:00
e6d3189edf
BREAKING CHANGE: ESM only * feat: esm * fix: linter oops
29 lines
609 B
JavaScript
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
|