processing of incoming message basically working

This commit is contained in:
Helmut Merz 2023-03-03 10:45:59 +01:00
parent 8a244aa1a3
commit bbeaa6a4e0
2 changed files with 13 additions and 4 deletions

View file

@ -36,6 +36,7 @@ const appdata = {
conf: {} as confdata, conf: {} as confdata,
components: {}, components: {},
output: '', output: '',
handle,
poll, poll,
mounted(name: string) { mounted(name: string) {
console.log('app mounted: ', name) console.log('app mounted: ', name)
@ -70,6 +71,13 @@ function poll() {
dopoll(this) dopoll(this)
} }
function handle(msg) {
const data = JSON.parse(msg.payload)
for (const k of Object.keys(data)) {
this.components.data.data[k] = data[k]
}
}
// basic functions - move to api.ts // basic functions - move to api.ts
function createSid(): string { function createSid(): string {
@ -100,8 +108,9 @@ async function dopoll(app: typeof appdata) {
let res = await fetch(app.conf.pollurl) let res = await fetch(app.conf.pollurl)
let msg = await res.json() let msg = await res.json()
console.log(msg) console.log(msg)
//app.handle(msg) if (msg.status === 'data') {
//app.newdata = data['status'] app.handle(msg)
}
} catch (error) { } catch (error) {
console.log(error) console.log(error)
await new Promise(r => setTimeout(r, 10000)) await new Promise(r => setTimeout(r, 10000))

View file

@ -2,9 +2,9 @@ export const api = {
path: '/api' path: '/api'
} }
export const polling = null // suppress polling //export const polling = null // suppress polling
export const xpolling = { export const polling = {
msgbase: ['system', 'poll', 'service', 'pclt-0001'] msgbase: ['system', 'poll', 'service', 'pclt-0001']
//msgbase: ['system', 'poll', 'session'] //msgbase: ['system', 'poll', 'session']
//msgbase: ['system', 'poll', 'interaction'] //msgbase: ['system', 'poll', 'interaction']