/* simple generic server sending an ack * */ import Base from '../src/base' let opts={id:'simple-ack-server-server'} ; (async () => { let server = new Base(opts) let opts2 = Object.assign({},opts) opts.port = process.env.UCI_PORT server.addSocket('server:tcp','s','t',opts) opts2.path = process.env.UCI_PATH || true server.addSocket('server:named-pipe','s','n',opts2) server.on('status',err => { console.log('STATUS EMITTED\n', err) }) // example return processor using a namespace, will take precidence over default and root namespaces server.cmds = { ack: (packet) => { packet.ack = true packet.cmd='reply' packet.msg ='ack via custom ack function' } } server.addNamespace('cmds') // comment this out to process via default ack let res = await server.init() if (res.error) { console.log('errors during init') process.kill(process.pid, 'SIGTERM') } console.log('sockets listening for an ack') })().catch(err => { console.error('FATAL: UNABLE TO START SYSTEM!\n',err) process.kill(process.pid, 'SIGTERM') })