MCPcopy Create free account
hub / github.com/cpaczek/skylight / syncApiTimer

Method syncApiTimer

server/src/datasource.ts:204–214  ·  view source on GitHub ↗

* The supplement timer should only run when the radio is primary — it exists * to keep landing aircraft alive when local ADS-B drops them. When the API is * itself the primary source, `tick()` already polls it, so a second timer just * doubles the request rate into airplanes.live's rate lim

()

Source from the content-addressed store, hash-verified

202 * disappearing and reappearing" in #15). Reconcile it against the live source.
203 */
204 private syncApiTimer(): void {
205 const want = this.o.source === "radio" && this.o.supplementApi;
206 if (want && !this.apiTimer && this.timer) {
207 void this.refreshApi();
208 this.apiTimer = setInterval(() => void this.refreshApi(), this.o.apiPollMs);
209 } else if (!want && this.apiTimer) {
210 clearInterval(this.apiTimer);
211 this.apiTimer = null;
212 this.lastApi = [];
213 }
214 }
215
216 private async fetchList(source: DataSource, now: number): Promise<Aircraft[] | null> {
217 const url = source === "radio" ? this.o.getConfig().radioUrl : this.buildApiUrl();

Callers 2

setSourceMethod · 0.95
startMethod · 0.95

Calls 1

refreshApiMethod · 0.95

Tested by

no test coverage detected