comparison 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
comparison
equal deleted inserted replaced
2416:61dc5bc8ce2e 2417:ae4b90efb55a
1 type Settings = Array<[string,string,string|number]>;
2
3 export class CollectorClient {
4 private settings: Settings;
5 constructor(public clientName:string) {
6 this.settings = [];
7 this.putLoop();
8 }
9 private async putLoop() {
10 await this.put();
11 setTimeout(() => {
12 this.putLoop();
13 }, 1000);
14 }
15 private async put() {
16 await fetch("/service/collector/attrs", {
17 method: "PUT",
18 body: JSON.stringify({
19 client: this.clientName,
20 clientSession: "unused",
21 sendTime: Date.now() / 1000,
22 settings: this.settings,
23 }),
24 });
25 }
26 public async updateSettings(settings: Settings) {
27 this.settings = settings;
28 await this.put()
29 }
30 }