From 3ce40c785d564a7a401f2e546bc475e3ba3640a9 Mon Sep 17 00:00:00 2001 From: Jesus-QC Date: Thu, 15 Dec 2022 18:31:33 +0100 Subject: [PATCH] bump + fix on auto crash handler --- SecretAdmin/Features/Server/Modules/SilentCrashHandler.cs | 7 +++++-- SecretAdmin/Features/Server/SocketServer.cs | 7 ++++--- SecretAdmin/SecretAdmin.csproj | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/SecretAdmin/Features/Server/Modules/SilentCrashHandler.cs b/SecretAdmin/Features/Server/Modules/SilentCrashHandler.cs index 0e31ca8..6bc6043 100644 --- a/SecretAdmin/Features/Server/Modules/SilentCrashHandler.cs +++ b/SecretAdmin/Features/Server/Modules/SilentCrashHandler.cs @@ -19,10 +19,13 @@ private async void CheckHeartbeats() { if (SecretAdmin.Program.Server.Status is ServerStatus.Offline) return; - + if (SecretAdmin.Program.Server.Status is ServerStatus.Idle) + { + await Task.Delay(5000); continue; - + } + if (secondsWithoutContact >= 16) { Log.Alert("Not Receiving Heartbeats... Waiting 5 last seconds."); diff --git a/SecretAdmin/Features/Server/SocketServer.cs b/SecretAdmin/Features/Server/SocketServer.cs index 367ba59..154a387 100644 --- a/SecretAdmin/Features/Server/SocketServer.cs +++ b/SecretAdmin/Features/Server/SocketServer.cs @@ -49,7 +49,7 @@ public void Stop() private async void ListenRequests() { byte[] codeBuffer = new byte[1]; - byte[] lenghtBuffer = new byte[sizeof(int)]; + byte[] lenghtBuffer = new byte[sizeof(int)]; // use size of an int since the lenght is sent as an int try { @@ -77,9 +77,10 @@ private async void ListenRequests() byte[] messageBuffer = new byte[length]; int messageBytesRead = await _stream.ReadAsync(messageBuffer.AsMemory(0, length), _cancellationTokenSource.Token); + // Null message is 99% a disconnection. if (codeBytes <= 0 || lengthBytes != sizeof(int) || messageBytesRead <= 0) { - if (SecretAdmin.Program.Server.Status == ServerStatus.Online) + if (SecretAdmin.Program.Server.Status != ServerStatus.Offline) Log.Alert("Socket disconnected."); break; @@ -181,7 +182,7 @@ private static void HandleAction(byte action) break; default: - Log.Alert($"Received unknown output code ({(OutputCodes)action}), possible buffer spam."); + Log.Alert($"Received unknown output code ({action}), possible buffer spam."); break; } } diff --git a/SecretAdmin/SecretAdmin.csproj b/SecretAdmin/SecretAdmin.csproj index 576310f..aa1358d 100644 --- a/SecretAdmin/SecretAdmin.csproj +++ b/SecretAdmin/SecretAdmin.csproj @@ -4,8 +4,8 @@ net6.0 ../Assets/SecretAdmin.ico true - 0.0.1.3 - 0.0.1.3 + 0.0.1.4 + 0.0.1.4 SecretAdmin Jesus-QC, SecretAdmin Server client for SCP:SL