You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-06 10:21:09 +09:00
Flushing delayed packets when shutting down NetPeer
This commit is contained in:
@@ -93,7 +93,7 @@ namespace Lidgren.Network
|
||||
{
|
||||
m_peer.VerifyNetworkThread();
|
||||
|
||||
// m_peer.LogDebug("Executing disconnect");
|
||||
//m_peer.LogDebug("Executing disconnect");
|
||||
|
||||
// clear send queues
|
||||
for (int i = 0; i < m_sendChannels.Length; i++)
|
||||
|
||||
@@ -212,9 +212,13 @@ namespace Lidgren.Network
|
||||
}
|
||||
}
|
||||
|
||||
FlushDelayedPackets();
|
||||
|
||||
// one final heartbeat, will send stuff and do disconnect
|
||||
Heartbeat();
|
||||
|
||||
Thread.Sleep(10);
|
||||
|
||||
lock (m_initializeLock)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -112,6 +112,18 @@ namespace Lidgren.Network
|
||||
}
|
||||
}
|
||||
|
||||
private void FlushDelayedPackets()
|
||||
{
|
||||
try
|
||||
{
|
||||
bool connectionReset;
|
||||
foreach (DelayedPacket p in m_delayedPackets)
|
||||
ActuallySendPacket(p.Data, p.Data.Length, p.Target, out connectionReset);
|
||||
m_delayedPackets.Clear();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
internal bool ActuallySendPacket(byte[] data, int numBytes, IPEndPoint target, out bool connectionReset)
|
||||
{
|
||||
connectionReset = false;
|
||||
@@ -272,6 +284,10 @@ namespace Lidgren.Network
|
||||
return;
|
||||
}
|
||||
|
||||
private void FlushDelayedPackets()
|
||||
{
|
||||
}
|
||||
|
||||
private void SendCallBack(IAsyncResult res)
|
||||
{
|
||||
NetException.Assert(res.IsCompleted == true);
|
||||
|
||||
Reference in New Issue
Block a user