mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 21:55:42 +12:00
Fix disconnect
This commit is contained in:
parent
c41364ab9e
commit
452a8ad60f
1 changed files with 5 additions and 6 deletions
|
@ -79,9 +79,7 @@ namespace HISP.Server
|
||||||
evt.Completed += receivePackets;
|
evt.Completed += receivePackets;
|
||||||
evt.SetBuffer(workBuffer, 0, workBuffer.Length);
|
evt.SetBuffer(workBuffer, 0, workBuffer.Length);
|
||||||
if (!clientSocket.ReceiveAsync(evt))
|
if (!clientSocket.ReceiveAsync(evt))
|
||||||
{
|
|
||||||
receivePackets(null, evt);
|
receivePackets(null, evt);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CreateClient(object sender, SocketAsyncEventArgs e)
|
public static void CreateClient(object sender, SocketAsyncEventArgs e)
|
||||||
|
@ -89,16 +87,17 @@ namespace HISP.Server
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Socket eSocket = e.AcceptSocket;
|
Socket eSocket = e.AcceptSocket;
|
||||||
new GameClient(eSocket);
|
if(eSocket != null)
|
||||||
|
new GameClient(eSocket);
|
||||||
e.AcceptSocket = null;
|
e.AcceptSocket = null;
|
||||||
} while (!GameServer.ServerSocket.AcceptAsync(e));
|
} while (!GameServer.ServerSocket.AcceptAsync(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
|
if (this.isDisconnecting)
|
||||||
|
return;
|
||||||
this.isDisconnecting = true;
|
this.isDisconnecting = true;
|
||||||
// Cant outright stop threads anymore in .NET core,
|
|
||||||
// Lets just let the thread stop gracefully.
|
|
||||||
|
|
||||||
// Stop Timers
|
// Stop Timers
|
||||||
if (inactivityTimer != null)
|
if (inactivityTimer != null)
|
||||||
|
@ -125,7 +124,7 @@ namespace HISP.Server
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// HI1 Packets are terminates by 0x00 so we have to read until we receive that terminator
|
// HI1 Packets are terminates by 0x00 so we have to read until we receive that terminator
|
||||||
|
ClientSocket.Poll(0, SelectMode.SelectRead);
|
||||||
if (!ClientSocket.Connected)
|
if (!ClientSocket.Connected)
|
||||||
{
|
{
|
||||||
Disconnect();
|
Disconnect();
|
||||||
|
|
Loading…
Add table
Reference in a new issue