uci-base/test/test.js

44 lines
1.3 KiB
JavaScript

import Base from '../src/base'
let wstest = new Base({})
;
(async () => {
wstest.on('error', err => {
console.log('ATTENTION! =========base instance error emitted ========')
console.log(err)
})
wstest.on('warn', warn => {
console.log('ATTENTION! =========base instance warning emitted ========')
console.log(warn)
})
// await wstest.addSocket('web0','s','w',{port:9000})
// await wstest.addSocket('m','s','m',{host:'nas.kebler.net'})
await wstest.addSocket('t1','s','t',{port:8001})
await wstest.addSocket('t2','s','t',{port:8001})
await wstest.addSocket('t3','s','t',{port:8003})
// await wstest.addSocket('mxxx','s','m',{host:'nas.kebler.net'})
// await wstest.addSocket('m2','s','m',{host:'nas.kebler.net'})
// await wstest.addSocket('web1','s','w',{port:9001})
let res = await wstest.init()
// await wstest.addSocket('web2','s','w',{port:9002})
if (res.errors) {
console.log('initialize errors reported')
console.log(res.errors)
}
console.log('sockets initialize responses\n',res.results)
wstest.push({cmd:'test', data:'test'})
// await wstest.addSocket('web2','s','w',{port:9002})
wstest.removeAllListeners('error')
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
process.kill(process.pid, 'SIGTERM')
})