From 6f4d1f8c05b603fa695929f81b631bf728bd0eb6 Mon Sep 17 00:00:00 2001 From: fan Date: Fri, 3 Nov 2023 10:54:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E9=98=85=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphic-pixi | 2 +- src/drawApp/lineNetApp.ts | 52 +++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/graphic-pixi b/graphic-pixi index 023c84c..3fe8f89 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit 023c84c4ccf7f38e477253e1b49856bfb50aca18 +Subproject commit 3fe8f895fa2458f7e7b93f24558fdc81a11c3f13 diff --git a/src/drawApp/lineNetApp.ts b/src/drawApp/lineNetApp.ts index 1cda92d..ae261f3 100644 --- a/src/drawApp/lineNetApp.ts +++ b/src/drawApp/lineNetApp.ts @@ -112,36 +112,13 @@ export function initLineNetApp(): IGraphicApp { pathLineList.forEach((pathLine) => { pathLine.visible = false; }); + handleSubscribe(lineNetApp); }); lineNetApp.registerGraphicTemplates(...graphicTemplate); RunLineOperateInteraction.init(lineNetApp); - lineNetApp.enableWsMassaging({ - wsUrl: `${getWebsocketUrl()}`, - token: getJwtToken() as string, - }); - lineNetApp.subscribe({ - destination: '/queue/lineNet', - - messageConverter: (message: Uint8Array) => { - const storage = state.WsLineNetMessage.deserialize(message); - const states: GraphicState[] = []; - storage.offset.forEach((item) => { - states.push(new TrainLineState(item)); - }); - return states; - }, - }); - lineNetApp.subscribe({ - destination: '/queue/xian/ncc/alert', - messageHandle: (message: Uint8Array) => { - const storage = alert.NccAlertInfoMessage.deserialize(message); - lineNetStore.setAlarmInfo(storage.messages as []); - }, - }); - let msgNotify: ReturnType | null = null; lineNetApp.on('websocket-connect-state-change', (connected) => { if (!connected && !msgNotify) { @@ -158,3 +135,30 @@ export function initLineNetApp(): IGraphicApp { }); return lineNetApp; } + +function handleSubscribe(lineNetApp: IGraphicApp) { + const lineNetStore = useLineNetStore(); + lineNetApp.enableWsMassaging({ + wsUrl: `${getWebsocketUrl()}`, + token: getJwtToken() as string, + }); + lineNetApp.subscribe({ + destination: '/queue/lineNet', + createOnNotFound: { graphicTypes: [TrainLine.Type] }, + messageConverter: (message: Uint8Array) => { + const storage = state.WsLineNetMessage.deserialize(message); + const states: GraphicState[] = []; + storage.offset.forEach((item) => { + states.push(new TrainLineState(item)); + }); + return states; + }, + }); + lineNetApp.subscribe({ + destination: '/queue/xian/ncc/alert', + messageHandle: (message: Uint8Array) => { + const storage = alert.NccAlertInfoMessage.deserialize(message); + lineNetStore.setAlarmInfo(storage.messages as []); + }, + }); +}