Update server.py

This commit is contained in:
Nova Cat 2024-12-12 13:35:02 -08:00
parent 2730cfa6c5
commit 6c1a890670

View file

@ -66,11 +66,13 @@ def pinger(nick, connection):
global property_list
while nick in property_list:
if (time.time() - property_list[nick]["last_ping"]) > 60 and not property_list[nick]["ping_pending"]:
if nick in property_list:
print("Sent ping message to " + nick)
property_list[nick]["ping_pending"] = True
time.sleep(0.5)
connection.sendall(bytes(f"PING {server}\r\n","UTF-8"))
elif property_list[nick]["ping_pending"] and ((time.time() - property_list[nick]["last_ping"]) > 255):
if nick in property_list:
property_list[nick]["cause"] = "Ping timeout: 255 seconds"
connection.shutdown(socket.SHUT_WR)
connection.close()