- `OnMessageReceived` von einem Delegaten in ein Ereignis umgewandelt, um die Ereignisabonnierung und -behandlung zu verbessern.
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
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<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 event ClientEvent OnMessageReceived = delegate { };
|
|
|
|
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 IEnumerable<AsymmetricPublicKey> PublicKeys { get; init; } = new List<AsymmetricPublicKey>();
|
|
} |