This commit is contained in:
soul-walker 2024-05-11 15:02:13 +08:00
parent 7f4719525a
commit 7dbd032eb8
2 changed files with 11 additions and 2 deletions

2
lib/index.d.ts vendored
View File

@ -1,4 +1,4 @@
/// <reference path="../global.d.ts" />
/// <reference types="global" />
export * as GraphicsExtras from '@pixi/graphics-extras';
export * from './app';
export * from './core';

View File

@ -5458,6 +5458,7 @@ 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') {
@ -5469,6 +5470,9 @@ class MqttMsgClient extends MessageClient {
handle(message);
}
}
else {
console.warn('未找到订阅的消息处理器', topic);
}
});
}
catch (err) {
@ -5492,13 +5496,15 @@ class MqttMsgClient extends MessageClient {
}
unsubscribe0(destination) {
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);
}
});
}
@ -6852,6 +6858,9 @@ class GraphicSceneBase extends EventEmitter {
this._dom = dom;
this.pixi.resizeTo = dom;
dom.appendChild(this.pixi.view);
// 绑定dom后先调整视口
this.updateViewport(dom.clientWidth, dom.clientHeight);
// 监听dom大小变化
this._viewportResizer = setInterval(() => {
this.updateViewport(dom.clientWidth, dom.clientHeight);
}, 1000);