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,
components: {},
output: '',
handle,
poll,
mounted(name: string) {
console.log('app mounted: ', name)
@ -70,6 +71,13 @@ function poll() {
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
function createSid(): string {
@ -100,8 +108,9 @@ async function dopoll(app: typeof appdata) {
let res = await fetch(app.conf.pollurl)
let msg = await res.json()
console.log(msg)
//app.handle(msg)
//app.newdata = data['status']
if (msg.status === 'data') {
app.handle(msg)
}
} catch (error) {
console.log(error)
await new Promise(r => setTimeout(r, 10000))

View file

@ -2,9 +2,9 @@ export const 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', 'session']
//msgbase: ['system', 'poll', 'interaction']