tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
ApiClientTokenRefreshRetryPolicy.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3
4using Microsoft.AspNetCore.SignalR.Client;
5
7{
12 {
17
22
29 {
30 this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
31 this.wrappedPolicy = wrappedPolicy ?? throw new ArgumentNullException(nameof(wrappedPolicy));
32 }
33
35 public TimeSpan? NextRetryDelay(RetryContext retryContext)
36 {
37 if (retryContext == null)
38 throw new ArgumentNullException(nameof(retryContext));
39
40 if (retryContext.PreviousRetryCount == 0)
42
43 return wrappedPolicy.NextRetryDelay(retryContext);
44 }
45
50 {
51 try
52 {
53 await apiClient.RefreshToken(CancellationToken.None);
54 }
55 catch
56 {
57 // intentionally ignored
58 }
59 }
60 }
61}
async ValueTask< bool > RefreshToken(CancellationToken cancellationToken)
Attempt to refresh the stored Bearer token in Headers.
Definition ApiClient.cs:336
A IRetryPolicy that attempts to refresh a given apiClient's token on the first disconnect.
async void AttemptTokenRefresh()
Attempt to refresh the apiClients token asynchronously.
ApiClientTokenRefreshRetryPolicy(ApiClient apiClient, IRetryPolicy wrappedPolicy)
Initializes a new instance of the ApiClientTokenRefreshRetryPolicy class.