command line option added
This commit is contained in:
parent
b6e34999b1
commit
14acc50732
10
src/main.ts
10
src/main.ts
@ -8,11 +8,16 @@ class MqttMongo {
|
||||
|
||||
exec(): void {
|
||||
this.mqttClient = Mqtt.connect(options['broker'])
|
||||
this.mqttClient.on('offline', () => { console.log("mqtt client is offline") })
|
||||
this.mqttClient.on('reconnect', () => { console.log("mqtt client is reconnecting") })
|
||||
this.mqttClient.on('close', () => { console.log("mqtt connection closed") })
|
||||
|
||||
this.mqttClient.on('connect', () => {
|
||||
console.log("connected to broker")
|
||||
console.log("mqtt client connected to broker")
|
||||
this.mqttClient.subscribe('MqttMongo/Command')
|
||||
this.mqttClient.publish('MqttMongo/Status', 'hello, started up')
|
||||
})
|
||||
|
||||
this.mqttClient.on('message', (topic : string, message : string) => {
|
||||
console.log("message received")
|
||||
console.log("topic %s", topic)
|
||||
@ -22,9 +27,6 @@ class MqttMongo {
|
||||
this.mqttClient.end()
|
||||
}
|
||||
})
|
||||
this.mqttClient.on('close', () => {
|
||||
console.log("bye bye")
|
||||
})
|
||||
|
||||
console.log("Hello world")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user