Skip to content

Commit

Permalink
Allow min resend time to be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Forest committed May 24, 2024
1 parent dc8a5db commit d5b7000
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Hazel/Udp/UdpConnection.Reliable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Hazel.Udp
{
partial class UdpConnection
{
private const int MinResendDelayMs = 50;
private const int MaxInitialResendDelayMs = 300;
private const int MaxAdditionalResendDelayMs = 1000;

Expand All @@ -30,6 +29,11 @@ partial class UdpConnection
/// </remarks>
public volatile int ResendTimeoutMs = 0;

/// <summary>
/// The minimum amount of time before a first resend can happen. Defaults to 50ms.
/// </summary>
public int MinResendDelayMs { get; set; } = 50;

/// <summary>
/// Max number of times to resend. 0 == no limit
/// </summary>
Expand Down Expand Up @@ -221,7 +225,7 @@ protected void AttachReliableID(SmartBuffer buffer, int offset, int length, Acti
int resendDelayMs = this.ResendTimeoutMs;
if (resendDelayMs <= 0)
{
resendDelayMs = (_pingMs * this.ResendPingMultiplier).ClampToInt(MinResendDelayMs, MaxInitialResendDelayMs);
resendDelayMs = (_pingMs * this.ResendPingMultiplier).ClampToInt(this.MinResendDelayMs, MaxInitialResendDelayMs);
}

Packet packet = this.PacketPool.GetObject();
Expand Down

0 comments on commit d5b7000

Please sign in to comment.