39 lines
1.1 KiB
C#

using Microsoft.AspNetCore.SignalR.Client;
namespace DigitalData.Auth.Client;
public class ClientParams
{
public string Url { get; set; } = string.Empty;
private readonly Lazy<IRetryPolicy?> _lazyRetryPolicy;
/// <summary>
/// Controls when the client attempts to reconnect and how many times it does so.
/// </summary>
public IRetryPolicy? RetryPolicy => _lazyRetryPolicy.Value;
/// <summary>
/// To simplify the assignment of <seealso cref="RetryPolicy"/>
/// </summary>
public Func<RetryContext, TimeSpan?>? NextRetryDelay { get; set; }
/// <summary>
/// To be able to serilize the simple <seealso cref="RetryPolicy"/>
/// </summary>
public TimeSpan? RetryDelay { get; set; }
public readonly ClientEvents Events = new();
public ClientParams()
{
_lazyRetryPolicy = new(() =>
{
if (RetryDelay is not null)
return new RetryPolicy(ctx => RetryDelay);
else if(NextRetryDelay is not null)
return new RetryPolicy(NextRetryDelay);
return null;
});
}
}