uci-socket/test/sockets/usocket.js

24 lines
500 B
JavaScript

import { Socket } from '../../src'
const USOCKET = 'usocket'
let socket = new Socket({path:USOCKET,name:'default-unix-socket'})
socket.test = 'at socket => '
socket.registerPacketProcessor(async function (packet) {
return new Promise((resolve) => {
packet.payload = 'overwrite default processor from instance '+ this.test + packet.payload
resolve(packet)
})
})
;
(async () => {
await socket.create()
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
})