uci-interrupt/examples/socket.js

33 lines
691 B
JavaScript

import Base from '@uci/base'
const PORT = process.env.PORT || 9000
let processor = new Base({sockets:'inter#s>t', inter:{port:PORT}, id:'interrupt-processor', useRootNS:true})
processor.interrupt = async function (packet) {
return new Promise((resolve) => {
console.log('interrupt occured')
console.dir(packet)
resolve({status: 'processed'})
})
}
processor.reply = async function (packet) {
return new Promise((resolve) => {
console.log('reply from interrupt with packet')
console.dir(packet)
resolve({status: 'processed'})
})
}
;
(async () => {
await processor.init()
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
})