From 47125301003004901fa84aa22f671663fea35774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Tue, 3 Jan 2023 13:30:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=98=E5=8C=96:=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96websocket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/application/websocketConfig.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/application/websocketConfig.py b/backend/application/websocketConfig.py index c3d4894..115138a 100644 --- a/backend/application/websocketConfig.py +++ b/backend/application/websocketConfig.py @@ -69,13 +69,15 @@ class DvadminWebSocket(AsyncJsonWebsocketConsumer): self.channel_name ) await self.accept() - # 发送连接成功 - #await self.send_json(set_message('system', 'SYSTEM', '连接成功')) # 主动推送消息 unread_count = await _get_message_unread(self.user_id) - await self.send_json( - set_message('system', 'SYSTEM', "请查看您的未读消息~", - unread=unread_count)) + if unread_count == 0: + # 发送连接成功 + await self.send_json(set_message('system', 'SYSTEM', '连接成功')) + else: + await self.send_json( + set_message('system', 'SYSTEM', "请查看您的未读消息~", + unread=unread_count)) except InvalidSignatureError: await self.disconnect(None)