diff options
Diffstat (limited to 'src/slskd/Network')
| -rw-r--r-- | src/slskd/Network/NetworkClient.cs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/slskd/Network/NetworkClient.cs b/src/slskd/Network/NetworkClient.cs index 30cc6971..c3ae9365 100644 --- a/src/slskd/Network/NetworkClient.cs +++ b/src/slskd/Network/NetworkClient.cs @@ -418,14 +418,7 @@ namespace slskd.Network return message; }; }) - .WithAutomaticReconnect(new[] - { - TimeSpan.FromSeconds(0), - TimeSpan.FromSeconds(1), - TimeSpan.FromSeconds(3), - TimeSpan.FromSeconds(10), - TimeSpan.FromSeconds(30), - }) + .WithAutomaticReconnect(new ControllerRetryPolicy(0, 1, 3, 10, 30, 60)) .Build(); HubConnection.Reconnected += HubConnection_Reconnected; @@ -453,5 +446,20 @@ namespace slskd.Network SyncRoot.Release(); } } + + private class ControllerRetryPolicy : IRetryPolicy + { + public ControllerRetryPolicy(params int[] intervals) + { + Intervals = intervals; + } + + private int[] Intervals { get; set; } + + public TimeSpan? NextRetryDelay(RetryContext retryContext) + { + return TimeSpan.FromSeconds(Intervals[Math.Min(retryContext.PreviousRetryCount, Intervals.Length - 1)]); + } + } } } |
