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; }
|
bool IsConnected { get; }
|
||||||
|
|
||||||
Task StartAsync();
|
Task StartAsync(CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
Task<bool> TryStartAsync();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,25 +36,17 @@ public class AuthClient : IAuthClient, IAsyncDisposable
|
|||||||
|
|
||||||
public IEnumerable<ClientPublicKey> PublicKeys => _params.PublicKeys;
|
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;
|
IsConnected = true;
|
||||||
await GetAllPublicKeysAsync();
|
await GetAllPublicKeysAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> TryStartAsync()
|
public async Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
try
|
await _connection.StopAsync(cancellationToken);
|
||||||
{
|
IsConnected = false;
|
||||||
await StartAsync();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
_logger?.LogError(ex, "{message}", ex.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task ReceivePublicKeyAsync(string issuer, string audience, string message) => Task.Run(() => _params.TriggerOnPublicReceivedEvent(this, issuer, audience, message, _logger));
|
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
|
// Stop test server
|
||||||
if (_app is not null)
|
if (_app is not null)
|
||||||
{
|
{
|
||||||
await _app.StopAsync();
|
await _app.DisposeAsync();
|
||||||
Console.WriteLine("Test server stopped.");
|
Console.WriteLine("Test server stopped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
"http": {
|
"http": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": false,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5075",
|
"applicationUrl": "http://localhost:5075",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
@ -22,7 +22,7 @@
|
|||||||
"https": {
|
"https": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": true,
|
"launchBrowser": false,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "https://localhost:7192;http://localhost:5075",
|
"applicationUrl": "https://localhost:7192;http://localhost:5075",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
@ -31,7 +31,7 @@
|
|||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
"launchBrowser": true,
|
"launchBrowser": false,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user