uci-socket/test/sockets/usocket-default-overwrite.mjs

24 lines
485 B
JavaScript

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