更新推送规则,避免心跳包刷屏

This commit is contained in:
CSSC-WORK\murmur 2024-10-24 14:38:21 +08:00
parent d2e6520011
commit e6757cfc4a

View File

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