From 452a8ad60f52f143cbd35df24be8e3fb31b4d417 Mon Sep 17 00:00:00 2001 From: Bluzume <39113159+KuromeSan@users.noreply.github.com> Date: Fri, 5 Nov 2021 05:26:18 -0400 Subject: [PATCH] Fix disconnect --- HorseIsleServer/HorseIsleServer/Server/GameClient.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/HorseIsleServer/HorseIsleServer/Server/GameClient.cs b/HorseIsleServer/HorseIsleServer/Server/GameClient.cs index 318c861..ea252e3 100644 --- a/HorseIsleServer/HorseIsleServer/Server/GameClient.cs +++ b/HorseIsleServer/HorseIsleServer/Server/GameClient.cs @@ -79,9 +79,7 @@ namespace HISP.Server evt.Completed += receivePackets; evt.SetBuffer(workBuffer, 0, workBuffer.Length); if (!clientSocket.ReceiveAsync(evt)) - { receivePackets(null, evt); - } } public static void CreateClient(object sender, SocketAsyncEventArgs e) @@ -89,16 +87,17 @@ namespace HISP.Server do { Socket eSocket = e.AcceptSocket; - new GameClient(eSocket); + if(eSocket != null) + new GameClient(eSocket); e.AcceptSocket = null; } while (!GameServer.ServerSocket.AcceptAsync(e)); } public void Disconnect() { + if (this.isDisconnecting) + return; this.isDisconnecting = true; - // Cant outright stop threads anymore in .NET core, - // Lets just let the thread stop gracefully. // Stop Timers if (inactivityTimer != null) @@ -125,7 +124,7 @@ namespace HISP.Server do { // HI1 Packets are terminates by 0x00 so we have to read until we receive that terminator - + ClientSocket.Poll(0, SelectMode.SelectRead); if (!ClientSocket.Connected) { Disconnect();