From e6757cfc4ad5532e229cf4ff6ab5b967db1aaeb8 Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Thu, 24 Oct 2024 14:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A8=E9=80=81=E8=A7=84?= =?UTF-8?q?=E5=88=99=EF=BC=8C=E9=81=BF=E5=85=8D=E5=BF=83=E8=B7=B3=E5=8C=85?= =?UTF-8?q?=E5=88=B7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index 3563294..160f30b 100755 --- a/server.py +++ b/server.py @@ -206,11 +206,12 @@ def load_cache(): return None -def update_pairs(addr, ccid, clear=0): +def update_pairs(addr, ccid, clear=0,cnt=0): """更新终端库 addr:绑定tcp地址 ccid:终端号 - clear:清空掉线终端""" + clear:清空掉线终端 + cnt:心跳包数量""" if not clear: # 添加或更新客户端 @@ -244,7 +245,11 @@ CCID:{ccid.decode()} clents = ' \n'+'\r\n'.join(od) if len(od) else "" t=f"在线终端已更新,数量{len(od)}。{clents}" logger.info(t) - s2wx("","",t) + cnt += 1 + # cnt为1或为10的倍数 + if cnt == 1 or cnt%10 == 0: + cnt = 0 + s2wx("","",t) def get_addr(ccid): @@ -548,7 +553,9 @@ class MyServer(socketserver.BaseRequestHandler): logger.info(t) logger.debug("[R] - {}",data.hex(" ")) # print(data.hex(" ")) - s2wx("","",t) + # 心跳报文17字节,避免推送心跳报文刷屏 + if len(data) > 17: + s2wx("","",t) # print("--",len(self.recDataBuff)) # print(self.recDataBuff[:]) if tt_decode(conn, data):