import { Socket } from '../src' async function packetProcess (packet) { return new Promise(resolve => { let res = {} if (packet.cmd !== 'doit') { res.response = `the payload sent was: ${packet.payload} with command ${packet.cmd}` } else { res.cmd = 'doit' res.response = 'take some action in browser like color a button green' } resolve (res) }) } // let test = new Test() let test = new Socket({port:8090, clientTracking:true}) test.registerPacketProcessor(packetProcess) ; (async () => { console.log(await test.create()) })().catch(err => { console.error('FATAL: UNABLE TO START SYSTEM!\n',err) })