Fixed issue of the client being killed before receiving the disconnect message.
This commit is contained in:
parent
4dae27001c
commit
7b58100546
3 changed files with 55 additions and 29 deletions
|
|
@ -91,32 +91,49 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
void GameHooks_Update(GameTime obj)
|
||||
{
|
||||
FlushAll();
|
||||
}
|
||||
|
||||
public void FlushAll()
|
||||
{
|
||||
for (int i = 0; i < Netplay.serverSock.Length; i++)
|
||||
{
|
||||
if (Netplay.serverSock[i] == null || !Netplay.serverSock[i].active)
|
||||
continue;
|
||||
|
||||
if (!Netplay.serverSock[i].tcpClient.Client.Poll(0, SelectMode.SelectWrite))
|
||||
continue;
|
||||
|
||||
byte[] buff = buffers[i].GetBytes(BytesPerUpdate);
|
||||
if (buff == null)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
Netplay.serverSock[i].tcpClient.Client.Send(buff);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
}
|
||||
Flush(Netplay.serverSock[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Flush(ServerSock socket)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (socket == null || !socket.active)
|
||||
return false;
|
||||
|
||||
if (!socket.tcpClient.Client.Poll(0, SelectMode.SelectWrite))
|
||||
return false;
|
||||
|
||||
byte[] buff = buffers[socket.whoAmI].GetBytes(BytesPerUpdate);
|
||||
if (buff == null)
|
||||
return false;
|
||||
|
||||
|
||||
socket.tcpClient.Client.Send(buff);
|
||||
return true;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.ConsoleError(e.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ServerHooks_SocketReset(ServerSock socket)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue