mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-22 20:55:52 +12:00
Fix Server shutdown
This commit is contained in:
parent
7ed10a6bca
commit
245f2d3e48
8 changed files with 276 additions and 112 deletions
|
@ -104,23 +104,32 @@ namespace HISP.Server
|
|||
}
|
||||
catch (Exception) { };
|
||||
}
|
||||
|
||||
private static bool acceptConnections(SocketAsyncEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e == null) return false;
|
||||
if (GameServer.ServerSocket == null) return false;
|
||||
return !GameServer.ServerSocket.AcceptAsync(e);
|
||||
}
|
||||
catch (Exception) { return false; }
|
||||
}
|
||||
public static void CreateClient(object sender, SocketAsyncEventArgs e)
|
||||
{
|
||||
do
|
||||
{
|
||||
Socket clientSocket = e.AcceptSocket;
|
||||
|
||||
if (GameServer.ServerSocket == null)
|
||||
return;
|
||||
if (clientSocket == null)
|
||||
continue;
|
||||
if (clientSocket.RemoteEndPoint == null)
|
||||
continue;
|
||||
|
||||
|
||||
connectedClients.Add(new GameClient(clientSocket));
|
||||
e.AcceptSocket = null;
|
||||
|
||||
} while (!GameServer.ServerSocket.AcceptAsync(e));
|
||||
} while (acceptConnections(e));
|
||||
}
|
||||
private void timeoutTimerTick(object state)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue