Mercurial > code > home > repos > light9
comparison 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 |
comparison
equal
deleted
inserted
replaced
2421:ac55319a2eac | 2422:62dc1b3644a0 |
---|---|
1 type Settings = Array<[string,string,string|number]>; | 1 import { Literal, NamedNode } from "n3"; |
2 | |
3 type Settings = Array<[NamedNode,NamedNode,Literal]>; | |
2 | 4 |
3 export class CollectorClient { | 5 export class CollectorClient { |
4 private settings: Settings; | 6 private settings: Settings; |
5 constructor(public clientName:string) { | 7 constructor(public clientName:string) { |
6 this.settings = []; | 8 this.settings = []; |
11 setTimeout(() => { | 13 setTimeout(() => { |
12 this.putLoop(); | 14 this.putLoop(); |
13 }, 1000); | 15 }, 1000); |
14 } | 16 } |
15 private async put() { | 17 private async put() { |
18 // todo: WS | |
16 await fetch("/service/collector/attrs", { | 19 await fetch("/service/collector/attrs", { |
17 method: "PUT", | 20 method: "PUT", |
18 body: JSON.stringify({ | 21 body: JSON.stringify({ |
19 client: this.clientName, | 22 client: this.clientName, |
20 clientSession: "unused", | 23 clientSession: "unused", |
21 sendTime: Date.now() / 1000, | 24 sendTime: Date.now() / 1000, |
22 settings: this.settings, | 25 settings: this.settings.map(([d,da,v]) => [d.value,da.value,v.value]) |
23 }), | 26 }), |
24 }); | 27 }); |
25 } | 28 } |
26 public async updateSettings(settings: Settings) { | 29 public async updateSettings(settings: Settings) { |
27 this.settings = settings; | 30 this.settings = settings; |