From 174794b0717ea8cffdb1c18afb2717912308f411 Mon Sep 17 00:00:00 2001 From: Macocian Alexandru Victor Date: Sun, 26 Nov 2023 02:30:03 +0100 Subject: [PATCH] Establish stricter client timeout (#20) --- GuildWarsPartySearch/Launch/Program.cs | 4 ++-- .../ServerHandlers/ConnectionMonitorHandler.cs | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/GuildWarsPartySearch/Launch/Program.cs b/GuildWarsPartySearch/Launch/Program.cs index 2a78ac5..f0d0637 100644 --- a/GuildWarsPartySearch/Launch/Program.cs +++ b/GuildWarsPartySearch/Launch/Program.cs @@ -32,7 +32,7 @@ private static async Task Main() .AddHandler(new HttpHandler() .AddHttpModule(new ContentModule())) .AddServerUsageMonitor(new TickrateEnforcer() { TicksPerSecond = 60, Silent = true }) - .SetScheduler(new TaskAwaiterScheduler()) + .SetScheduler(new FireTasksAndForgetScheduler()) .WithLoggingMessageContents(false); var serverOptions = httpsServer.ServiceManager.GetRequiredService>(); httpsServer.WithCertificate(serverOptions.Value.Certificate); @@ -45,7 +45,7 @@ private static async Task Main() httpServer.AddHandler(new HttpHandler() .AddHttpModule(new ContentModule())) .AddServerUsageMonitor(new TickrateEnforcer { TicksPerSecond = 10, Silent = true }) - .SetScheduler(new TaskAwaiterScheduler()) + .SetScheduler(new FireTasksAndForgetScheduler()) .WithLoggingMessageContents(false); var httpsServerTask = httpsServer.RunAsync(CancellationTokenSource.Token); diff --git a/GuildWarsPartySearch/ServerHandlers/ConnectionMonitorHandler.cs b/GuildWarsPartySearch/ServerHandlers/ConnectionMonitorHandler.cs index 87732e8..1259043 100644 --- a/GuildWarsPartySearch/ServerHandlers/ConnectionMonitorHandler.cs +++ b/GuildWarsPartySearch/ServerHandlers/ConnectionMonitorHandler.cs @@ -35,11 +35,8 @@ void IHandler.Tick(MTSC.ServerSide.Server server) { if (DateTime.Now - client.LastActivityTime > inactivityTimeout) { - if (!IsConnected(client.Socket)) - { - server.Log("Disconnected: " + client.Socket.RemoteEndPoint?.ToString()); - client.ToBeRemoved = true; - } + server.Log("Disconnected: " + client.Socket.RemoteEndPoint?.ToString()); + client.ToBeRemoved = true; } } }