1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 07:06:30 +09:00

NetPeerConfiguration.UseCoalescing added

This commit is contained in:
lidgren
2010-06-09 11:39:52 +00:00
parent caf68daab7
commit 10ae62c4cd
2 changed files with 17 additions and 2 deletions

View File

@@ -182,7 +182,8 @@ namespace Lidgren.Network
m_lastSentUnsentMessages = now;
}
int mtu = m_peerConfiguration.MaximumTransmissionUnit;
int mtu = m_peerConfiguration.m_maximumTransmissionUnit;
bool useCoalescing = m_peerConfiguration.m_useMessageCoalescing;
float throttleThreshold = m_peerConfiguration.m_throttlePeakBytes;
if (m_throttleDebt < throttleThreshold)
@@ -204,7 +205,7 @@ namespace Lidgren.Network
int msgPayloadLength = msg.LengthBytes;
msg.m_lastSentTime = now;
if (ptr > 0 && (ptr + NetPeer.kMaxPacketHeaderSize + msgPayloadLength) > mtu)
if (!useCoalescing || (ptr > 0 && (ptr + NetPeer.kMaxPacketHeaderSize + msgPayloadLength) > mtu))
{
// send packet and start new packet
bool connectionReset;
@@ -561,6 +562,9 @@ namespace Lidgren.Network
{
if (msg.IsSent)
throw new NetException("Message has already been sent!");
NetException.Assert(sequenceChannel >= 0 && sequenceChannel < NetConstants.NetChannelsPerDeliveryMethod, "Sequence channel must be between 0 and NetConstants.NetChannelsPerDeliveryMethod (" + NetConstants.NetChannelsPerDeliveryMethod + ")");
msg.m_type = (NetMessageType)((int)method + sequenceChannel);
EnqueueOutgoingMessage(msg);
}

View File

@@ -37,6 +37,7 @@ namespace Lidgren.Network
internal int m_receiveBufferSize, m_sendBufferSize;
internal int m_defaultOutgoingMessageCapacity;
internal int m_maximumTransmissionUnit;
internal bool m_useMessageCoalescing;
internal int m_maximumConnections;
internal NetIncomingMessageType m_disabledTypes;
internal int m_throttleBytesPerSecond;
@@ -85,6 +86,7 @@ namespace Lidgren.Network
m_handshakeAttemptDelay = 1.0f;
m_handshakeMaxAttempts = 7;
m_maxRecycledBytesKept = 128 * 1024;
m_useMessageCoalescing = true;
m_loss = 0.0f;
m_minimumOneWayLatency = 0.0f;
@@ -254,6 +256,15 @@ namespace Lidgren.Network
}
}
/// <summary>
/// Gets or sets if message coalescing (sending multiple messages in a single packet) should be used. Normally this should be true.
/// </summary>
public bool UseMessageCoalescing
{
get { return m_useMessageCoalescing; }
set { m_useMessageCoalescing = value; }
}
/// <summary>
/// Gets or sets the maximum amount of connections this peer can hold. Cannot be changed once NetPeer is initialized.
/// </summary>