uci-socket/test/sockets/usocket-packet-alt-context.mjs

26 lines
534 B
JavaScript
Raw Normal View History

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