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