Processor class introduced
This commit is contained in:
47
src/main.ts
47
src/main.ts
@ -1,41 +1,28 @@
|
||||
import * as log from './log'
|
||||
import * as mqtt from './mqttdispatcher'
|
||||
import * as callchain from './callchain'
|
||||
import * as plugintest1 from './plugintest1'
|
||||
|
||||
|
||||
class Dispatcher {
|
||||
private _mqttDispatcher: mqtt.MqttDispatcher
|
||||
log.info("Dispatcher starting")
|
||||
export const dispatcher = new mqtt.MqttDispatcher()
|
||||
dispatcher.register('IoT/test', 'print1', (message: any) : any => {
|
||||
log.info("Callback for IoT/test")
|
||||
log.info(`message is ${message}`)
|
||||
return `<<${message}>>`
|
||||
})
|
||||
dispatcher.register('IoT/test', 'print2', (message: any) : any => {
|
||||
log.info("Callback for IoT/test")
|
||||
log.info(`message is ${message}`)
|
||||
return `<<${message}>>`
|
||||
})
|
||||
dispatcher.register('IoT/test', 'null1', mqtt.passThrough)
|
||||
dispatcher.register('IoT/test', 'null2', mqtt.passThrough)
|
||||
|
||||
constructor() {
|
||||
this._mqttDispatcher = new mqtt.MqttDispatcher()
|
||||
plugintest1.pluginTest1Start(dispatcher)
|
||||
|
||||
this._mqttDispatcher.register('IoT/test', 'print1', (message: any) : any => {
|
||||
log.info("Callback for IoT/test")
|
||||
log.info(`message is ${message}`)
|
||||
return `<<${message}>>`
|
||||
})
|
||||
this._mqttDispatcher.register('IoT/test', 'print2', (message: any) : any => {
|
||||
log.info("Callback for IoT/test")
|
||||
log.info(`message is ${message}`)
|
||||
return `<<${message}>>`
|
||||
})
|
||||
this._mqttDispatcher.register('IoT/test', 'null1', mqtt.passThrough)
|
||||
this._mqttDispatcher.register('IoT/test', 'null2', mqtt.passThrough)
|
||||
}
|
||||
|
||||
exec() : void {
|
||||
log.info("Dispatcher starting")
|
||||
|
||||
this._mqttDispatcher.exec()
|
||||
|
||||
log.info("Dispatcher running")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const dispatcher = new Dispatcher()
|
||||
dispatcher.exec()
|
||||
log.info("Dispatcher running")
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user