You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-18 08:06:33 +09:00
Crude Path MTU detection added
This commit is contained in:
@@ -44,7 +44,7 @@ namespace Lidgren.Network
|
||||
throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
|
||||
|
||||
int len = msg.LengthBytes;
|
||||
if (len <= m_configuration.MaximumTransmissionUnit)
|
||||
if (len <= recipient.m_currentMTU)
|
||||
{
|
||||
Interlocked.Increment(ref msg.m_recyclingCount);
|
||||
return recipient.EnqueueMessage(msg, method, sequenceChannel);
|
||||
@@ -57,6 +57,18 @@ namespace Lidgren.Network
|
||||
}
|
||||
}
|
||||
|
||||
internal int GetMTU(IList<NetConnection> recipients)
|
||||
{
|
||||
int mtu = int.MaxValue;
|
||||
foreach (NetConnection conn in recipients)
|
||||
{
|
||||
int cmtu = conn.m_currentMTU;
|
||||
if (cmtu < mtu)
|
||||
mtu = cmtu;
|
||||
}
|
||||
return mtu;
|
||||
}
|
||||
|
||||
public void SendMessage(NetOutgoingMessage msg, IList<NetConnection> recipients, NetDeliveryMethod method, int sequenceChannel)
|
||||
{
|
||||
if (msg == null)
|
||||
@@ -68,6 +80,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");
|
||||
|
||||
int mtu = GetMTU(recipients);
|
||||
|
||||
int len = msg.LengthBytes;
|
||||
if (len <= m_configuration.MaximumTransmissionUnit)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user