Mercurial > code > home > repos > light9
diff web/collector/CollectorClient.ts @ 2417:ae4b90efb55a
start calibration tool
author | drewp@bigasterisk.com |
---|---|
date | Mon, 20 May 2024 01:28:12 -0700 |
parents | |
children | 62dc1b3644a0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/collector/CollectorClient.ts Mon May 20 01:28:12 2024 -0700 @@ -0,0 +1,30 @@ +type Settings = Array<[string,string,string|number]>; + +export class CollectorClient { + private settings: Settings; + constructor(public clientName:string) { + this.settings = []; + this.putLoop(); + } + private async putLoop() { + await this.put(); + setTimeout(() => { + this.putLoop(); + }, 1000); + } + private async put() { + await fetch("/service/collector/attrs", { + method: "PUT", + body: JSON.stringify({ + client: this.clientName, + clientSession: "unused", + sendTime: Date.now() / 1000, + settings: this.settings, + }), + }); + } + public async updateSettings(settings: Settings) { + this.settings = settings; + await this.put() + } +}