34 lines
890 B
JavaScript
34 lines
890 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) {
|
|
// return new Promise((resolve) => {
|
|
// console.log('====== packet pushed from server ======')
|
|
// console.dir(packet)
|
|
// // setTimeout(resolve('done'),100)
|
|
// resolve('done')
|
|
// })
|
|
console.log('====== packet pushed from server ======')
|
|
console.dir(packet)
|
|
// setTimeout(resolve('done'),100)
|
|
return Promise.resolve('done')
|
|
|
|
}
|
|
|
|
client.registerPacketProcessor(process)
|
|
|
|
;
|
|
(async () => {
|
|
|
|
console.log(await client.connect())
|
|
|
|
|
|
})().catch(err => {
|
|
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
|
|
})
|