Skip to content

Commit

Permalink
Fixes ping server
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman committed Sep 19, 2024
1 parent 41bca83 commit fe3f895
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Projects/Server/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ private static void HandleClosed()

World.WaitForWriteCompletion();
World.ExitSerializationThreads();
PingServer.Shutdown();
TcpServer.Shutdown();

if (!_crashed)
{
Expand Down
14 changes: 11 additions & 3 deletions Projects/Server/Network/PingServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static void Start()
return;
}

HashSet<IPEndPoint> listeningAddresses = new HashSet<IPEndPoint>();
List<UdpClient> listeners = new List<UdpClient>();
HashSet<IPEndPoint> listeningAddresses = [];
List<UdpClient> listeners = [];

foreach (var serverIpep in ServerConfiguration.Listeners)
{
Expand All @@ -70,7 +70,7 @@ public static void Start()
}

listeners.Add(listener);
new Thread(BeginAcceptingUdpRequest).Start(listener);
BeginAcceptingUdpRequest(listener);
}

foreach (var ipep in listeningAddresses)
Expand Down Expand Up @@ -140,4 +140,12 @@ private static async void BeginAcceptingUdpRequest(object state)
}
}
}

public static void Shutdown()
{
foreach (var listener in Listeners)
{
listener.Close();
}
}
}
2 changes: 2 additions & 0 deletions Projects/Server/Network/TcpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/

using System;

Check warning on line 16 in Projects/Server/Network/TcpServer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant using directive

Using directive is not required by the code and can be safely removed
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Threading;

Check warning on line 24 in Projects/Server/Network/TcpServer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant using directive

Using directive is not required by the code and can be safely removed
using Server.Logging;
using Server.Misc;

Expand Down

0 comments on commit fe3f895

Please sign in to comment.