| 125 | service.timer.interval = 500; |
| 126 | } |
| 127 | update(service) { |
| 128 | const index = this.services.indexOf(service); |
| 129 | if (index < 0) throw new Error("service not found"); |
| 130 | |
| 131 | if (!service.updater) { |
| 132 | service.updater = Timer.set(updater => { |
| 133 | this.write(this.reply(null, 0x04 | 0x8000, service)); |
| 134 | updater.interval += 250; |
| 135 | if (updater.interval >= 1500) { |
| 136 | Timer.clear(updater); |
| 137 | delete service.updater; |
| 138 | delete service.update; |
| 139 | } |
| 140 | else |
| 141 | Timer.schedule(updater, updater.interval, 250); |
| 142 | }, 0, 250); |
| 143 | } |
| 144 | else |
| 145 | Timer.schedule(service.updater, 0, 250); |
| 146 | service.updater.interval = 0; |
| 147 | } |
| 148 | remove(service, callback) { |
| 149 | if ("string" === typeof service) { |
| 150 | service += ".local"; |