diff --git a/src/message/MqttBroker.ts b/src/message/MqttBroker.ts index f79c70f..990ee26 100644 --- a/src/message/MqttBroker.ts +++ b/src/message/MqttBroker.ts @@ -85,12 +85,14 @@ export class MqttMsgClient extends MessageClient { } unsubscribe0(destination: string): void { console.debug('MQTT取消订阅执行', destination); + // 删除指定订阅的消息处理器 + this.subMsgHandler.delete(destination); + // 通知服务器取消订阅 this.cli.unsubscribe(destination, (error, packet) => { if (error) { console.warn('MQTT 取消订阅失败', error); } else { console.debug('MQTT 取消订阅成功', packet); - this.subMsgHandler.delete(destination); } }); }