You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 23: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)
|
if (msg.m_isSent)
|
||||||
throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
|
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;
|
int len = msg.LengthBytes;
|
||||||
if (len <= recipient.m_currentMTU)
|
if (len <= recipient.m_currentMTU)
|
||||||
{
|
{
|
||||||
@@ -91,6 +93,8 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
int mtu = GetMTU(recipients);
|
int mtu = GetMTU(recipients);
|
||||||
|
|
||||||
|
msg.m_isSent = true;
|
||||||
|
|
||||||
int len = msg.LengthBytes;
|
int len = msg.LengthBytes;
|
||||||
if (len <= m_configuration.MaximumTransmissionUnit)
|
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 + ")");
|
throw new NetException("Unconnected messages too long! Must be shorter than NetConfiguration.MaximumTransmissionUnit (currently " + m_configuration.MaximumTransmissionUnit + ")");
|
||||||
|
|
||||||
msg.m_messageType = NetMessageType.Unconnected;
|
msg.m_messageType = NetMessageType.Unconnected;
|
||||||
|
msg.m_isSent = true;
|
||||||
|
|
||||||
Interlocked.Increment(ref msg.m_recyclingCount);
|
Interlocked.Increment(ref msg.m_recyclingCount);
|
||||||
m_unsentUnconnectedMessages.Enqueue(new NetTuple<IPEndPoint, NetOutgoingMessage>(recipient, msg));
|
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 + ")");
|
throw new NetException("Unconnected messages too long! Must be shorter than NetConfiguration.MaximumTransmissionUnit (currently " + m_configuration.MaximumTransmissionUnit + ")");
|
||||||
|
|
||||||
msg.m_messageType = NetMessageType.Unconnected;
|
msg.m_messageType = NetMessageType.Unconnected;
|
||||||
|
msg.m_isSent = true;
|
||||||
|
|
||||||
Interlocked.Add(ref msg.m_recyclingCount, recipients.Count);
|
Interlocked.Add(ref msg.m_recyclingCount, recipients.Count);
|
||||||
foreach(IPEndPoint ep in recipients)
|
foreach(IPEndPoint ep in recipients)
|
||||||
|
|||||||
@@ -27,6 +27,18 @@ namespace UnitTests
|
|||||||
|
|
||||||
EncryptionTests.Run(peer);
|
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");
|
peer.Shutdown("bye");
|
||||||
|
|
||||||
// read all message
|
// read all message
|
||||||
|
|||||||
Reference in New Issue
Block a user