You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-15 22:56:30 +09:00
Bug not detecting multiple sends of same message fixed
This commit is contained in:
@@ -45,6 +45,8 @@ namespace Lidgren.Network
|
||||
if (msg.m_isSent)
|
||||
throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
|
||||
|
||||
msg.m_isSent = true;
|
||||
|
||||
int len = msg.LengthBytes;
|
||||
if (len <= recipient.m_currentMTU)
|
||||
{
|
||||
@@ -91,6 +93,8 @@ namespace Lidgren.Network
|
||||
|
||||
int mtu = GetMTU(recipients);
|
||||
|
||||
msg.m_isSent = true;
|
||||
|
||||
int len = msg.LengthBytes;
|
||||
if (len <= m_configuration.MaximumTransmissionUnit)
|
||||
{
|
||||
@@ -158,6 +162,7 @@ namespace Lidgren.Network
|
||||
throw new NetException("Unconnected messages too long! Must be shorter than NetConfiguration.MaximumTransmissionUnit (currently " + m_configuration.MaximumTransmissionUnit + ")");
|
||||
|
||||
msg.m_messageType = NetMessageType.Unconnected;
|
||||
msg.m_isSent = true;
|
||||
|
||||
Interlocked.Increment(ref msg.m_recyclingCount);
|
||||
m_unsentUnconnectedMessages.Enqueue(new NetTuple<IPEndPoint, NetOutgoingMessage>(recipient, msg));
|
||||
@@ -178,6 +183,7 @@ namespace Lidgren.Network
|
||||
throw new NetException("Unconnected messages too long! Must be shorter than NetConfiguration.MaximumTransmissionUnit (currently " + m_configuration.MaximumTransmissionUnit + ")");
|
||||
|
||||
msg.m_messageType = NetMessageType.Unconnected;
|
||||
msg.m_isSent = true;
|
||||
|
||||
Interlocked.Add(ref msg.m_recyclingCount, recipients.Count);
|
||||
foreach(IPEndPoint ep in recipients)
|
||||
|
||||
@@ -27,6 +27,18 @@ namespace UnitTests
|
||||
|
||||
EncryptionTests.Run(peer);
|
||||
|
||||
var om = peer.CreateMessage();
|
||||
peer.SendUnconnectedMessage(om, new IPEndPoint(IPAddress.Loopback, 14242));
|
||||
try
|
||||
{
|
||||
peer.SendUnconnectedMessage(om, new IPEndPoint(IPAddress.Loopback, 14242));
|
||||
}
|
||||
catch (NetException nex)
|
||||
{
|
||||
if (nex.Message != "This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently")
|
||||
throw nex;
|
||||
}
|
||||
|
||||
peer.Shutdown("bye");
|
||||
|
||||
// read all message
|
||||
|
||||
Reference in New Issue
Block a user