feat(AuthClient): try-start entfernen und Abbruch-Token hinzufügen, um asynchron zu starten

This commit is contained in:
Developer 02
2025-03-11 14:50:10 +01:00
parent 29ad0554bc
commit 4ccf7a20b3
4 changed files with 10 additions and 20 deletions

View File

@@ -36,25 +36,17 @@ public class AuthClient : IAuthClient, IAsyncDisposable
public IEnumerable<ClientPublicKey> PublicKeys => _params.PublicKeys;
public async Task StartAsync()
public async Task StartAsync(CancellationToken cancellationToken = default)
{
await _connection.StartAsync();
await _connection.StartAsync(cancellationToken);
IsConnected = true;
await GetAllPublicKeysAsync();
}
public async Task<bool> TryStartAsync()
public async Task StopAsync(CancellationToken cancellationToken)
{
try
{
await StartAsync();
return true;
}
catch(Exception ex)
{
_logger?.LogError(ex, "{message}", ex.Message);
return false;
}
await _connection.StopAsync(cancellationToken);
IsConnected = false;
}
public Task ReceivePublicKeyAsync(string issuer, string audience, string message) => Task.Run(() => _params.TriggerOnPublicReceivedEvent(this, issuer, audience, message, _logger));