From 6ddf2d89376f6542b792f955edd1db5875da7a9c Mon Sep 17 00:00:00 2001 From: fan Date: Mon, 31 Jul 2023 11:19:19 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E6=B5=8B=E8=AF=95=E5=8F=91=E5=B8=83"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4a36daf843240d7209a0cba5c1a785e47643cc77. --- src/drawApp/lineNetApp.ts | 74 +++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/drawApp/lineNetApp.ts b/src/drawApp/lineNetApp.ts index a024ea6..7379894 100644 --- a/src/drawApp/lineNetApp.ts +++ b/src/drawApp/lineNetApp.ts @@ -107,43 +107,43 @@ export async function loadLineNetDatas(app: GraphicApp) { pathLineList.forEach((pathLine) => { pathLine.visible = false; }); - // app.enableWsMassaging({ - // wsUrl: `${getWebsocketUrl()}`, - // token: getJwtToken() as string, - // }); - // app.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; - // }, - // }); - // app.subscribe({ - // destination: '/queue/xian/ncc/alert', - // messageHandle: (message: Uint8Array) => { - // const storage = alert.NccAlertInfoMessage.deserialize(message); - // lineNetStore.setAlarmInfo(storage.messages as []); - // }, - // }); - // let msgNotify: null | ((props?: QNotifyUpdateOptions | undefined) => void) = - // null; - // app.on('websocket-connect-state-change', (connected) => { - // if (!connected && !msgNotify) { - // msgNotify = Notify.create({ - // type: 'negative', - // timeout: 0, - // position: 'top-right', - // message: '通信链接已断开!', - // }); - // } else if (msgNotify && connected) { - // msgNotify(); - // msgNotify = null; - // } - // }); + app.enableWsMassaging({ + wsUrl: `${getWebsocketUrl()}`, + token: getJwtToken() as string, + }); + app.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; + }, + }); + app.subscribe({ + destination: '/queue/xian/ncc/alert', + messageHandle: (message: Uint8Array) => { + const storage = alert.NccAlertInfoMessage.deserialize(message); + lineNetStore.setAlarmInfo(storage.messages as []); + }, + }); + let msgNotify: null | ((props?: QNotifyUpdateOptions | undefined) => void) = + null; + app.on('websocket-connect-state-change', (connected) => { + if (!connected && !msgNotify) { + msgNotify = Notify.create({ + type: 'negative', + timeout: 0, + position: 'top-right', + message: '通信链接已断开!', + }); + } else if (msgNotify && connected) { + msgNotify(); + msgNotify = null; + } + }); } else { app.loadGraphic([]); }