feat(AuthClient): try-start entfernen und Abbruch-Token hinzufügen, um asynchron zu starten
This commit is contained in:
parent
29ad0554bc
commit
4ccf7a20b3
@ -4,7 +4,5 @@ public interface IAuthClient : IAuthListenHandler, IAuthSenderHandler
|
||||
{
|
||||
bool IsConnected { get; }
|
||||
|
||||
Task StartAsync();
|
||||
|
||||
Task<bool> TryStartAsync();
|
||||
Task StartAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -104,7 +104,7 @@ public class AuthClientTests
|
||||
// Stop test server
|
||||
if (_app is not null)
|
||||
{
|
||||
await _app.StopAsync();
|
||||
await _app.DisposeAsync();
|
||||
Console.WriteLine("Test server stopped.");
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchBrowser": false,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5075",
|
||||
"environmentVariables": {
|
||||
@ -22,7 +22,7 @@
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchBrowser": false,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7192;http://localhost:5075",
|
||||
"environmentVariables": {
|
||||
@ -31,7 +31,7 @@
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchBrowser": false,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user