2018-01-08 13:06:01 -08:00
|
|
|
import Consumer from '../src/consumer'
|
|
|
|
|
2018-03-02 08:34:10 -08:00
|
|
|
// const client1= new Consumer({name:'example-consumer1' })
|
|
|
|
const client= new Consumer({path:true, name:'example-consumer' })
|
2018-01-08 13:06:01 -08:00
|
|
|
|
2018-03-02 08:34:10 -08:00
|
|
|
let packet = {name: 'client', cmd:'doit', data:'data sent by client'}
|
2018-01-08 13:06:01 -08:00
|
|
|
|
2018-01-13 20:46:14 -08:00
|
|
|
// This is your client handler object waiting on a message to do something
|
2018-01-30 16:59:57 -08:00
|
|
|
const process = function (packet) {
|
|
|
|
console.log(`Packet from ${packet.name} Processed by Socket: ${packet.status}`)
|
2018-01-10 15:03:32 -08:00
|
|
|
}
|
|
|
|
|
2018-03-02 08:34:10 -08:00
|
|
|
client.registerPacketProcessor(process)
|
2018-01-30 16:59:57 -08:00
|
|
|
|
2018-01-08 13:06:01 -08:00
|
|
|
;
|
|
|
|
(async () => {
|
|
|
|
|
2018-02-12 14:41:06 -08:00
|
|
|
|
|
|
|
|
|
|
|
// await Promise.all([client1.connect(),client2.connect()])
|
2018-03-02 08:34:10 -08:00
|
|
|
await client.connect()
|
|
|
|
console.log('=========\n',await client.send(packet))
|
|
|
|
client.end()
|
2018-01-08 13:06:01 -08:00
|
|
|
|
|
|
|
})().catch(err => {
|
|
|
|
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
|
|
|
|
})
|