callchains implemented
This commit is contained in:
44
src/main.ts
44
src/main.ts
@ -1,5 +1,7 @@
|
||||
import * as log from './log'
|
||||
import * as mqtt from './mqttclient'
|
||||
import * as callchain from './callchain'
|
||||
|
||||
|
||||
class Dispatcher {
|
||||
private _mqttClient: mqtt.MqttClient
|
||||
@ -7,13 +9,18 @@ class Dispatcher {
|
||||
constructor() {
|
||||
this._mqttClient = new mqtt.MqttClient()
|
||||
|
||||
this._mqttClient.register('IoT/test', 'print', (message: any) : any => {
|
||||
this._mqttClient.registerCallbackFunc('IoT/test', 'print1', (message: any) : any => {
|
||||
log.info("Callback for IoT/test")
|
||||
log.info(`message is ${message}`)
|
||||
return `<<${message}>>`
|
||||
})
|
||||
this._mqttClient.register('IoT/Device/#', 'null1', mqtt.passThrough)
|
||||
this._mqttClient.register('IoT/Device/#', 'null2', mqtt.passThrough)
|
||||
this._mqttClient.registerCallbackFunc('IoT/test', 'print2', (message: any) : any => {
|
||||
log.info("Callback for IoT/test")
|
||||
log.info(`message is ${message}`)
|
||||
return `<<${message}>>`
|
||||
})
|
||||
this._mqttClient.registerCallbackFunc('IoT/test', 'null1', mqtt.passThrough)
|
||||
this._mqttClient.registerCallbackFunc('IoT/test', 'null2', mqtt.passThrough)
|
||||
}
|
||||
|
||||
exec() : void {
|
||||
@ -23,12 +30,43 @@ class Dispatcher {
|
||||
|
||||
log.info("Dispatcher running")
|
||||
}
|
||||
|
||||
test() : void {
|
||||
log.info("Sending test data")
|
||||
this._mqttClient.test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// callchain.registerChainItemFunc('first', (message : any) : any => {
|
||||
// log.info(`first callback ${message}`)
|
||||
// return `<${message}>`
|
||||
// })
|
||||
|
||||
// callchain.registerChainItemFunc('second', (message : any) : any => {
|
||||
// log.info(`second callback ${message}`)
|
||||
// return `<${message}>`
|
||||
// })
|
||||
|
||||
// callchain.registerChainItemFunc('third', (message : any) : any => {
|
||||
// log.info(`third callback ${message}`)
|
||||
// return `<${message}>`
|
||||
// })
|
||||
|
||||
// callchain.begin()
|
||||
|
||||
// callchain.send('test1')
|
||||
// callchain.send('test2')
|
||||
// callchain.send('test3')
|
||||
// callchain.send('test4')
|
||||
|
||||
const dispatcher = new Dispatcher()
|
||||
dispatcher.exec()
|
||||
|
||||
dispatcher.test()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user