This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
|
||||
namespace ShrinkNetwork
|
||||
{
|
||||
public sealed class ShrinkKcpTransportOptions
|
||||
{
|
||||
public uint ConversationId { get; set; }
|
||||
public int Mtu { get; set; } = 1200;
|
||||
public int SendWindow { get; set; } = 256;
|
||||
public int ReceiveWindow { get; set; } = 256;
|
||||
public bool NoDelay { get; set; } = true;
|
||||
public int Interval { get; set; } = 10;
|
||||
public int Resend { get; set; } = 2;
|
||||
public bool DisableCongestionControl { get; set; } = true;
|
||||
public int UpdateIntervalMs { get; set; } = 10;
|
||||
public int ConnectTimeoutMs { get; set; } = 5000;
|
||||
public int HandshakeRetryMs { get; set; } = 1000;
|
||||
public int IdleTimeoutMs { get; set; } = 15000;
|
||||
public int ReceiveBufferSize { get; set; } = 64 * 1024;
|
||||
public int MaxMessageSize { get; set; } = 64 * 1024;
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
if (Mtu < 576 || Mtu > 1400)
|
||||
throw new ArgumentOutOfRangeException(nameof(Mtu), "MTU must be between 576 and 1400.");
|
||||
if (SendWindow <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(SendWindow));
|
||||
if (ReceiveWindow <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(ReceiveWindow));
|
||||
if (Interval <= 0 || Interval > 5000)
|
||||
throw new ArgumentOutOfRangeException(nameof(Interval));
|
||||
if (Resend < 0 || Resend > 2)
|
||||
throw new ArgumentOutOfRangeException(nameof(Resend));
|
||||
if (UpdateIntervalMs <= 0 || UpdateIntervalMs > 5000)
|
||||
throw new ArgumentOutOfRangeException(nameof(UpdateIntervalMs));
|
||||
if (ConnectTimeoutMs <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(ConnectTimeoutMs));
|
||||
if (HandshakeRetryMs <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(HandshakeRetryMs));
|
||||
if (IdleTimeoutMs <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(IdleTimeoutMs));
|
||||
if (ReceiveBufferSize <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(ReceiveBufferSize));
|
||||
if (MaxMessageSize <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(MaxMessageSize));
|
||||
}
|
||||
|
||||
public ShrinkKcpTransportOptions Clone()
|
||||
{
|
||||
return new ShrinkKcpTransportOptions
|
||||
{
|
||||
ConversationId = ConversationId,
|
||||
Mtu = Mtu,
|
||||
SendWindow = SendWindow,
|
||||
ReceiveWindow = ReceiveWindow,
|
||||
NoDelay = NoDelay,
|
||||
Interval = Interval,
|
||||
Resend = Resend,
|
||||
DisableCongestionControl = DisableCongestionControl,
|
||||
UpdateIntervalMs = UpdateIntervalMs,
|
||||
ConnectTimeoutMs = ConnectTimeoutMs,
|
||||
HandshakeRetryMs = HandshakeRetryMs,
|
||||
IdleTimeoutMs = IdleTimeoutMs,
|
||||
ReceiveBufferSize = ReceiveBufferSize,
|
||||
MaxMessageSize = MaxMessageSize
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user