Skip to content

Commit

Permalink
Implement unreliable message size limit error.
Browse files Browse the repository at this point in the history
Not a proper solution to the unreliable fragmentation issue, but better than nothing.

See lidgren#148
  • Loading branch information
PJB3005 committed Oct 30, 2020
1 parent 7cb5d9c commit e24f1a7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Lidgren.Network/NetUnreliableSenderChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ internal override NetSendResult Enqueue(NetOutgoingMessage message)
return NetSendResult.Dropped;
}

if (message.LengthBits >= ushort.MaxValue
&& m_connection.m_peerConfiguration.UnreliableSizeBehaviour == NetUnreliableSizeBehaviour.IgnoreMTU)
{
// drop message
this.m_connection.m_peer.LogError(
string.Format("Unreliable message max size exceeded: {0} bits (max {1})",
message.LengthBits,
ushort.MaxValue));
return NetSendResult.Dropped;
}

m_queuedSends.Enqueue(message);
m_connection.m_peer.m_needFlushSendQueue = true; // a race condition to this variable will simply result in a single superflous call to FlushSendQueue()
return NetSendResult.Sent;
Expand Down

0 comments on commit e24f1a7

Please sign in to comment.