using DigitalData.Auth.Client; using Microsoft.AspNetCore.SignalR.Client; using Microsoft.Extensions.Logging; namespace DigitalData.Auth.Client; public class ClientParams { public string Url { get; set; } = string.Empty; private readonly Lazy _lazyRetryPolicy; /// /// Controls when the client attempts to reconnect and how many times it does so. /// public IRetryPolicy? RetryPolicy => _lazyRetryPolicy.Value; /// /// To simplify the assignment of /// public Func? NextRetryDelay { get; set; } /// /// To be able to serilize the simple /// public TimeSpan? RetryDelay { get; set; } public event ClientEvent OnMessageReceived = ClientEvents.UpdatePublicKeys; internal void TriggerOnMessageReceived(AuthClient client, string issuer, string audience, string key, ILogger? logger = null) => OnMessageReceived(client, issuer, audience, key, logger); 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; }); } public List PublicKeys { get; init; } = new(); }