import Base from '../src/base' const USOCKET = __dirname + '/sample.sock' const delay = time => new Promise(res=>setTimeout(()=>res(),time)) ; (async () => { // let app = new Base({com:'us,uc,ts,tc', id:'example', path: USOCKET, log:false}) let app = new Base({com:'us,uc,ts,tc', id:'example'}) await app.init() console.log('ready=============sending============') let packet = {cmd:'echo', data:'some data to echo'} await app.send(packet) app.write = function(packet){ packet.cmd='log' packet.response='return of write command' return packet } app.write2 = function(packet){ packet.cmd='log' packet.response='return of write2 command' return packet } app.registerPacketContext(app) packet = {cmd:'write', data:'data to write'} await app.send(packet) packet = {cmd:'write2', data:'data to write'} await app.send(packet) await delay(2000) process.kill(process.pid, 'SIGTERM') })().catch(err => { console.error('FATAL: UNABLE TO START SYSTEM!\n',err) })