修改消息订阅顺序问题

This commit is contained in:
walker 2023-07-28 16:10:24 +08:00
parent a1a9eac588
commit e521b07d86
3 changed files with 12 additions and 8 deletions

View File

@ -11,4 +11,6 @@ export function getHttpBase() {
export function getWebsocketUrl() {
const host = '192.168.3.233:8000';
return `ws://${host}/connection/websocket`;
// const host = '192.168.3.233:9081';
// return `ws://${host}/ws-default`;
}

View File

@ -104,6 +104,9 @@ export class WsMsgCli {
const cli = WsMsgCli.client;
cli.on('connected', () => {
WsMsgCli.emitConnectStateChangeEvent(true);
WsMsgCli.appMsgBroker.forEach((broker) => {
broker.resubscribe();
});
});
cli.on('disconnected', () => {
WsMsgCli.emitConnectStateChangeEvent(false);
@ -123,11 +126,11 @@ export class WsMsgCli {
static trySubscribe(
destination: string,
handler: MessageHandler
): ISubscription {
return WsMsgCli.client.subscribe(destination, handler);
// if (WsMsgCli.isConnected()) {
// }
// return undefined;
): ISubscription | undefined {
if (WsMsgCli.isConnected()) {
return WsMsgCli.client.subscribe(destination, handler);
}
return undefined;
}
static registerAppMsgBroker(broker: AppWsMsgBroker) {

View File

@ -160,8 +160,6 @@ function toggleFullscreen(e: unknown): void {
onMounted(() => {
console.log('绘制应用layout mounted');
const basic = Base64.decode('Zm9vOmJhcg==');
console.log(basic);
const dom = document.getElementById('draw-app-container');
if (dom) {
const drawApp = drawStore.initDrawApp(dom);
@ -175,10 +173,11 @@ onMounted(() => {
protocol: 'json',
wsUrl: getWebsocketUrl(),
token:
// 'Bearer eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJzZWxmIiwic3ViIjoiNiIsImV4cCI6MTY5MDc5MDczMSwiaWF0IjoxNjkwNTMxNTMxfQ.caXc0jfI766p57Qx6hnuMp6XPpnBvfQuBeFI5-mlOHLBEK6Js13jy0cfGX_FxICWUGEEV0lYI8U1EfCDYPyQ38i4BcHe88mq4jK6byztuyWtkWjx4nOMcCwO-haOfJ2E0pIJOOm5aFBWT2YRdlb63gjvDbyLwdsvO1wr4-QSkB2uyyKpTaFnYP4OiF264UdN-XYuME5k_RkjcinvcYjPR7WI2YCu_Sg0exzqQW03pspTyx5ozbuc_3JSkOA7g4aqnizMJgVAsCbTwYBnfvLClDbcztkyaqbhN5pA4Eme_yPos4ISfufjR7TyUROVp7yEV6gSLHRtPulageQxNhltXA',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTA2MTM0MzUsImlkIjo2LCJvcmlnX2lhdCI6MTY5MDUyNzAzNSwic3ViIjoiNiJ9.sRCFji8-90hXK_l_O2ScQHYSpmnw8TILmrZGCyR9RCo',
});
drawApp.subscribe({
destination: 'test2',
destination: '/queue/lineNet',
messageHandle: (msg) => {
// const storage = graphicData.RtssGraphicStorage.deserialize(msg);
console.log('设备消息处理', msg);