Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from Jesus-QC/dev
Browse files Browse the repository at this point in the history
bump
  • Loading branch information
Jesus-QC authored Dec 16, 2022
2 parents 8c94bc8 + 3ce40c7 commit 463bd88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions SecretAdmin/Features/Server/Modules/SilentCrashHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
7 changes: 4 additions & 3 deletions SecretAdmin/Features/Server/SocketServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions SecretAdmin/SecretAdmin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon>../Assets/SecretAdmin.ico</ApplicationIcon>
<Optimize>true</Optimize>
<AssemblyVersion>0.0.1.3</AssemblyVersion>
<FileVersion>0.0.1.3</FileVersion>
<AssemblyVersion>0.0.1.4</AssemblyVersion>
<FileVersion>0.0.1.4</FileVersion>
<Title>SecretAdmin</Title>
<Authors>Jesus-QC, SecretAdmin</Authors>
<Description>Server client for SCP:SL</Description>
Expand Down

0 comments on commit 463bd88

Please sign in to comment.