更新推送规则,避免心跳包刷屏
This commit is contained in:
parent
d2e6520011
commit
e6757cfc4a
15
server.py
15
server.py
@ -206,11 +206,12 @@ def load_cache():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def update_pairs(addr, ccid, clear=0):
|
def update_pairs(addr, ccid, clear=0,cnt=0):
|
||||||
"""更新终端库
|
"""更新终端库
|
||||||
addr:绑定tcp地址
|
addr:绑定tcp地址
|
||||||
ccid:终端号
|
ccid:终端号
|
||||||
clear:清空掉线终端"""
|
clear:清空掉线终端
|
||||||
|
cnt:心跳包数量"""
|
||||||
|
|
||||||
if not clear:
|
if not clear:
|
||||||
# 添加或更新客户端
|
# 添加或更新客户端
|
||||||
@ -244,7 +245,11 @@ CCID:{ccid.decode()}
|
|||||||
clents = ' \n'+'\r\n'.join(od) if len(od) else ""
|
clents = ' \n'+'\r\n'.join(od) if len(od) else ""
|
||||||
t=f"在线终端已更新,数量{len(od)}。{clents}"
|
t=f"在线终端已更新,数量{len(od)}。{clents}"
|
||||||
logger.info(t)
|
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):
|
def get_addr(ccid):
|
||||||
@ -548,7 +553,9 @@ class MyServer(socketserver.BaseRequestHandler):
|
|||||||
logger.info(t)
|
logger.info(t)
|
||||||
logger.debug("[R] - {}",data.hex(" "))
|
logger.debug("[R] - {}",data.hex(" "))
|
||||||
# print(data.hex(" "))
|
# print(data.hex(" "))
|
||||||
s2wx("","",t)
|
# 心跳报文17字节,避免推送心跳报文刷屏
|
||||||
|
if len(data) > 17:
|
||||||
|
s2wx("","",t)
|
||||||
# print("--",len(self.recDataBuff))
|
# print("--",len(self.recDataBuff))
|
||||||
# print(self.recDataBuff[:])
|
# print(self.recDataBuff[:])
|
||||||
if tt_decode(conn, data):
|
if tt_decode(conn, data):
|
||||||
|
Loading…
Reference in New Issue
Block a user