Timeout clients that did not sent for 10s

This commit is contained in:
ChillerDragon 2022-11-12 15:58:08 +01:00
parent 821036fba4
commit c770695f22
2 changed files with 2 additions and 1 deletions

View file

@ -87,7 +87,7 @@ class GameServer
timeout_ids = []
@server.clients.each do |id, client|
diff = now - client.last_recv_time
timeout_ids.push(id) if diff > 1
timeout_ids.push(id) if diff > 10
end
timeout_ids.each do |id|

View file

@ -287,6 +287,7 @@ class TeeworldsServer
@clients.each do |id, client|
next unless packet.addr.eq(client.addr)
client.last_recv_time = Time.now
packet.client_id = id
packet.client = client
end