changes
This commit is contained in:
parent
81e9a51e20
commit
3b25d3df89
11
src/main.ts
11
src/main.ts
@ -4,14 +4,13 @@ class MqttMongo {
|
|||||||
private mqttClient : Mqtt.Client
|
private mqttClient : Mqtt.Client
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
|
||||||
|
|
||||||
exec(): void {
|
|
||||||
this.mqttClient = Mqtt.connect(options['broker'])
|
this.mqttClient = Mqtt.connect(options['broker'])
|
||||||
this.mqttClient.on('offline', () => { console.log("mqtt client is offline") })
|
this.mqttClient.on('offline', () => { console.log("mqtt client is offline") })
|
||||||
this.mqttClient.on('reconnect', () => { console.log("mqtt client is reconnecting") })
|
this.mqttClient.on('reconnect', () => { console.log("mqtt client is reconnecting") })
|
||||||
this.mqttClient.on('close', () => { console.log("mqtt connection closed") })
|
this.mqttClient.on('close', () => { console.log("mqtt connection closed") })
|
||||||
|
}
|
||||||
|
|
||||||
|
exec(): void {
|
||||||
this.mqttClient.on('connect', () => {
|
this.mqttClient.on('connect', () => {
|
||||||
console.log("mqtt client connected to broker")
|
console.log("mqtt client connected to broker")
|
||||||
this.mqttClient.subscribe('MqttMongo/Command')
|
this.mqttClient.subscribe('MqttMongo/Command')
|
||||||
@ -27,8 +26,6 @@ class MqttMongo {
|
|||||||
this.mqttClient.end()
|
this.mqttClient.end()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log("Hello world")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,4 +37,6 @@ options
|
|||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
|
|
||||||
const mqttMongo = new MqttMongo()
|
const mqttMongo = new MqttMongo()
|
||||||
mqttMongo.exec()
|
mqttMongo.exec()
|
||||||
|
|
||||||
|
console.log("MqttMongo started")
|
Loading…
x
Reference in New Issue
Block a user