1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-15 22:56:30 +09:00

recycle outgoing messages even when throwing exception because of invalid recipients

This commit is contained in:
Michael Lidgren
2015-05-13 14:38:30 +02:00
parent 513d4d6da1
commit b374cf7e00
2 changed files with 9 additions and 0 deletions

View File

@@ -157,6 +157,7 @@ namespace Lidgren.Network
if (serverConnection == null)
{
LogWarning("Cannot send message, no server connection!");
Recycle(msg);
return NetSendResult.FailedNotConnected;
}

View File

@@ -104,9 +104,17 @@ namespace Lidgren.Network
if (msg == null)
throw new ArgumentNullException("msg");
if (recipients == null)
{
if (msg.m_isSent == false)
Recycle(msg);
throw new ArgumentNullException("recipients");
}
if (recipients.Count < 1)
{
if (msg.m_isSent == false)
Recycle(msg);
throw new NetException("recipients must contain at least one item");
}
if (method == NetDeliveryMethod.Unreliable || method == NetDeliveryMethod.ReliableUnordered)
NetException.Assert(sequenceChannel == 0, "Delivery method " + method + " cannot use sequence channels other than 0!");
if (msg.m_isSent)