1
0
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:
lidgren
2012-05-26 09:08:04 +00:00
parent 5859971a7e
commit a5781b4688
3 changed files with 21 additions and 1 deletions

View File

@@ -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++)

View File

@@ -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

View File

@@ -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);