修复bug:rts-sim-testing-client的#2issue: joylink/rts-sim-testing-client#2 (comment)

This commit is contained in:
soul-walker 2024-05-11 10:36:18 +08:00
parent baa468200a
commit 110a1bfa00

View File

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