2018-01-08 13:06:01 -08:00
|
|
|
import { Socket } from '../src'
|
|
|
|
|
2018-02-12 14:41:06 -08:00
|
|
|
;
|
2018-01-08 13:06:01 -08:00
|
|
|
(async () => {
|
|
|
|
|
2018-01-20 14:30:21 -08:00
|
|
|
class Test extends Socket {
|
2018-02-03 13:33:25 -08:00
|
|
|
constructor(opts) {
|
|
|
|
super(opts)
|
2018-01-08 13:06:01 -08:00
|
|
|
}
|
|
|
|
|
2018-02-03 13:33:25 -08:00
|
|
|
async _packetProcess(packet) {
|
2018-02-13 13:51:58 -08:00
|
|
|
console.log('packet being processed at socket')
|
2018-01-13 20:46:14 -08:00
|
|
|
if (packet.cmd) return await this[packet.cmd](packet.data,packet.name)
|
|
|
|
return {error: 'no command in packet', packet: packet }
|
2018-01-08 13:06:01 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
async doit(data,name) {
|
2018-02-12 14:41:06 -08:00
|
|
|
return new Promise(resolve => {
|
|
|
|
let res = {}
|
2018-02-13 13:51:58 -08:00
|
|
|
console.log('data sent to doit = ', data)
|
2018-02-12 14:41:06 -08:00
|
|
|
res.status ='success'
|
|
|
|
res.name = name
|
|
|
|
res.cmd = 'reply'
|
|
|
|
res.data = 'this would be response data from socket doit function'
|
|
|
|
resolve(res)
|
|
|
|
})
|
|
|
|
|
2018-01-08 13:06:01 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-12 14:41:06 -08:00
|
|
|
let test = new Test({np:true})
|
2018-01-20 14:30:21 -08:00
|
|
|
await test.create()
|
2018-01-08 13:06:01 -08:00
|
|
|
|
|
|
|
})().catch(err => {
|
|
|
|
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
|
|
|
|
})
|