processing of incoming message basically working
This commit is contained in:
parent
8a244aa1a3
commit
bbeaa6a4e0
2 changed files with 13 additions and 4 deletions
|
@ -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))
|
||||||
|
|
|
@ -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']
|
||||||
|
|
Loading…
Add table
Reference in a new issue