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):