Processor class introduced

This commit is contained in:
Wolfgang Hottgenroth
2017-08-09 11:37:22 +02:00
parent 09d7ea8ace
commit 16313c868f
7 changed files with 124 additions and 55 deletions

View File

@ -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")