aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/slskd/Core/ConnectionWatchdog.cs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/slskd/Core/ConnectionWatchdog.cs b/src/slskd/Core/ConnectionWatchdog.cs
index f8461033..a598ff7a 100644
--- a/src/slskd/Core/ConnectionWatchdog.cs
+++ b/src/slskd/Core/ConnectionWatchdog.cs
@@ -48,7 +48,7 @@ namespace slskd
IStateMonitor<State> state)
{
Client = soulseekClient;
- Options = optionsMonitor;
+ OptionsMonitor = optionsMonitor;
State = state;
WatchdogTimer = new System.Timers.Timer()
@@ -59,6 +59,8 @@ namespace slskd
};
WatchdogTimer.Elapsed += (sender, args) => _ = AttemptReconnect();
+
+ OptionsMonitor.OnChange(options => OptionsChanged(options));
}
/// <summary>
@@ -69,7 +71,7 @@ namespace slskd
private ISoulseekClient Client { get; }
private bool Disposed { get; set; }
private ILogger Log { get; } = Serilog.Log.ForContext<Application>();
- private IOptionsMonitor<Options> Options { get; set; }
+ private IOptionsMonitor<Options> OptionsMonitor { get; set; }
private IStateMonitor<State> State { get; }
private SemaphoreSlim SyncRoot { get; } = new SemaphoreSlim(1, 1);
private System.Timers.Timer WatchdogTimer { get; }
@@ -141,6 +143,17 @@ namespace slskd
}
}
+ private void OptionsChanged(Options options)
+ {
+ // it's possible that a user begins changing connection settings in an attempt to get the client to connect
+ // if they edit the options _at all_, assume this is the case and restart the retry loop from the beginning
+ if (IsEnabled)
+ {
+ Log.Information("Options changed, restarting (re)connection process...");
+ Restart();
+ }
+ }
+
private async Task AttemptReconnect(int attempts = 1)
{
// semaphore is obtained here and released only when the reconnect attempt is complete, so