From c770695f22c475962c2bb5271aa528e38ea88e46 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sat, 12 Nov 2022 15:58:08 +0100 Subject: [PATCH] Timeout clients that did not sent for 10s --- lib/game_server.rb | 2 +- lib/teeworlds_server.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/game_server.rb b/lib/game_server.rb index 4fc1ed7..d34c38a 100644 --- a/lib/game_server.rb +++ b/lib/game_server.rb @@ -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| diff --git a/lib/teeworlds_server.rb b/lib/teeworlds_server.rb index 0001f8d..226c3e0 100644 --- a/lib/teeworlds_server.rb +++ b/lib/teeworlds_server.rb @@ -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