From 403a90f0161601151d09a3183c519132606735fc Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Mon, 15 Jul 2024 17:36:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/Meeting/index.tsx | 1 - src/utils/package/signalr.ts | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index c3a52ff..082b928 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -166,7 +166,6 @@ const Meeting: React.FC = () => { getRoomUser() break; } - }) }, []) diff --git a/src/utils/package/signalr.ts b/src/utils/package/signalr.ts index f9d3591..2c5aed6 100644 --- a/src/utils/package/signalr.ts +++ b/src/utils/package/signalr.ts @@ -17,18 +17,19 @@ export const startSignalr = () => { } export const onSignalr = (callBack: Function) => { - connection.on("ReceiveMessage", (uid: string, userName: string, message: string) => { - callBack({ - key:'ReceiveMessage', - uid, message, userName - }) - }); - connection.on("RefreshUserList", () => { - callBack({ - key: 'ReceiveMessage' - }) - }); - + if (connection){ + connection.on("ReceiveMessage", (uid: string, userName: string, message: string) => { + callBack({ + key:'ReceiveMessage', + uid, message, userName + }) + }); + connection.on("RefreshUserList", () => { + callBack({ + key: 'ReceiveMessage' + }) + }); + } } export const onInvoke = async (str: string, data: any) => { switch (str) {