Mercurial > code > home > repos > light9
annotate web/collector/CollectorClient.ts @ 2422:62dc1b3644a0
collector client uses rdf types, not strings
author | drewp@bigasterisk.com |
---|---|
date | Tue, 21 May 2024 16:11:28 -0700 |
parents | ae4b90efb55a |
children |
rev | line source |
---|---|
2422
62dc1b3644a0
collector client uses rdf types, not strings
drewp@bigasterisk.com
parents:
2417
diff
changeset
|
1 import { Literal, NamedNode } from "n3"; |
62dc1b3644a0
collector client uses rdf types, not strings
drewp@bigasterisk.com
parents:
2417
diff
changeset
|
2 |
62dc1b3644a0
collector client uses rdf types, not strings
drewp@bigasterisk.com
parents:
2417
diff
changeset
|
3 type Settings = Array<[NamedNode,NamedNode,Literal]>; |
2417 | 4 |
5 export class CollectorClient { | |
6 private settings: Settings; | |
7 constructor(public clientName:string) { | |
8 this.settings = []; | |
9 this.putLoop(); | |
10 } | |
11 private async putLoop() { | |
12 await this.put(); | |
13 setTimeout(() => { | |
14 this.putLoop(); | |
15 }, 1000); | |
16 } | |
17 private async put() { | |
2422
62dc1b3644a0
collector client uses rdf types, not strings
drewp@bigasterisk.com
parents:
2417
diff
changeset
|
18 // todo: WS |
2417 | 19 await fetch("/service/collector/attrs", { |
20 method: "PUT", | |
21 body: JSON.stringify({ | |
22 client: this.clientName, | |
23 clientSession: "unused", | |
24 sendTime: Date.now() / 1000, | |
2422
62dc1b3644a0
collector client uses rdf types, not strings
drewp@bigasterisk.com
parents:
2417
diff
changeset
|
25 settings: this.settings.map(([d,da,v]) => [d.value,da.value,v.value]) |
2417 | 26 }), |
27 }); | |
28 } | |
29 public async updateSettings(settings: Settings) { | |
30 this.settings = settings; | |
31 await this.put() | |
32 } | |
33 } |