更新部分提示算法
临时关闭主动切断客户端的功能
This commit is contained in:
parent
e6026ac646
commit
02a4d37cc3
27
server.py
27
server.py
@ -100,18 +100,21 @@ def update_pairs(addr, ccid, clear=0):
|
||||
ccid:终端号
|
||||
clear:清空掉线终端"""
|
||||
|
||||
if ccid and not clear:
|
||||
if not clear:
|
||||
# 添加或更新客户端
|
||||
pp[addr] = ccid
|
||||
p.clear
|
||||
|
||||
if ccid not in p:
|
||||
t = f"""*信息:*
|
||||
天通终端上线。
|
||||
CCID:{ccid.decode()}
|
||||
地址:{str(addr.getpeername())}
|
||||
"""
|
||||
print(t)
|
||||
s2wx("","天通终端上线",t)
|
||||
# p[ccid] = addr
|
||||
pp[addr] = ccid
|
||||
p.clear
|
||||
|
||||
else:
|
||||
del p[ccid]
|
||||
del pp[addr]
|
||||
@ -343,23 +346,25 @@ class MyServer(socketserver.BaseRequestHandler):
|
||||
)
|
||||
s2wx("","",f"接收到新数据,长度{len(data)}字节。")
|
||||
if tt_decode(conn, data):
|
||||
conn.close()
|
||||
print(self.client_address, "疑是非法连接,已切断。")
|
||||
break
|
||||
self.err= "切断。"
|
||||
print(self.client_address, "疑是非法连接")
|
||||
# conn.close()
|
||||
# break
|
||||
|
||||
def finish(self):
|
||||
|
||||
if self.request in pp:
|
||||
t = f"""终端下线了。{self.err}
|
||||
CCID:{pp[self.request].decode()}
|
||||
地址:{str(self.client_address)}
|
||||
"""
|
||||
地址:{str(self.client_address)}"""
|
||||
print(t)
|
||||
s2wx("","天通终端下线了",t)
|
||||
print("终端",self.client_address,"下线了。")
|
||||
# print("终端",self.client_address,"下线了。",self.err)
|
||||
update_pairs(self.request,get_ccid(self.request),1)
|
||||
else:
|
||||
print("客户端",self.client_address,"已断开。")
|
||||
s2wx("天通消息","TCP客户端断开",f"TCP客户端{str(self.client_address)}已断开连接。{self.err}")
|
||||
t= f"TCP客户端{str(self.client_address)}已断开连接。{self.err}"
|
||||
print(t)
|
||||
s2wx("天通消息","TCP客户端断开",t)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user