uci-socket/examples/client-push.js

25 lines
598 B
JavaScript

import Consumer from '../src/consumer'
// const client1= new Consumer({name:'example-consumer1' })
const client= new Consumer({path:true, name:'example-consumer'})
// let packet = {name: 'client', cmd:'doit', data:'data sent by client'}
// This is your client handler object waiting on a message to do something
const process = async function (packet) {
console.log('====== packet pushed from server ======')
console.dir(packet)
}
client.registerPacketProcessor(process)
;
(async () => {
client.connect()
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
})