MQTT添加消息日志

This commit is contained in:
soul-walker 2024-05-11 14:28:50 +08:00
parent 110a1bfa00
commit b29036144b

View File

@ -52,6 +52,7 @@ export class MqttMsgClient extends MessageClient {
this.emit('error', error);
});
this.cli.on('message', (topic, message) => {
console.debug('MQTT 收到消息', topic, message);
const handle = this.subMsgHandler.get(topic);
if (handle) {
if (this.options.protocol === 'json') {
@ -61,6 +62,8 @@ export class MqttMsgClient extends MessageClient {
// 字节流
handle(message);
}
} else {
console.warn('未找到订阅的消息处理器', topic);
}
});
} catch (err) {