aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-07-10 12:22:50 -0500
committerJP Dillingham <jpdillingham@gmail.com>2022-07-10 12:22:50 -0500
commit623702e58199131afe8ad58c19d0feabb066c211 (patch)
treea486fc95c9f146092d147de627350655710e810c /src
parentf22f333391f45e6d93c0df014fd06b543449e7f3 (diff)
downloadslskd-623702e58199131afe8ad58c19d0feabb066c211.tar.gz
start connection watchdog on qualifying disconnect, stop on connect
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Application.cs26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 2c1a63af..af553475 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -76,6 +76,7 @@ namespace slskd
IOptionsMonitor<Options> optionsMonitor,
IManagedState<State> state,
ISoulseekClient soulseekClient,
+ IConnectionWatchdog connectionWatchdog,
ITransferTracker transferTracker,
ITransferService transferService,
IBrowseTracker browseTracker,
@@ -139,11 +140,14 @@ namespace slskd
Client.DistributedNetworkStateChanged += Client_DistributedNetworkStateChanged;
Client.DownloadDenied += (e, args) => Log.Information("Download of {Filename} from {Username} was denied: {Message}", args.Filename, args.Username, args.Message);
Client.DownloadFailed += (e, args) => Log.Information("Download of {Filename} from {Username} failed", args.Filename, args.Username);
+
+ ConnectionWatchdog = connectionWatchdog;
}
private ISoulseekClient Client { get; set; }
private IRoomService RoomService { get; set; }
private IBrowseTracker BrowseTracker { get; set; }
+ private IConnectionWatchdog ConnectionWatchdog { get; }
private IConversationTracker ConversationTracker { get; set; }
private ILogger Log { get; set; } = Serilog.Log.ForContext<Application>();
private ConcurrentDictionary<string, ILogger> Loggers { get; } = new ConcurrentDictionary<string, ILogger>();
@@ -355,6 +359,7 @@ namespace slskd
private void Client_Connected(object sender, EventArgs e)
{
+ ConnectionWatchdog.Stop();
Log.Information("Connected to the Soulseek server");
}
@@ -402,28 +407,12 @@ namespace slskd
}
else if (args.Exception is KickedFromServerException)
{
- Log.Error("Disconnected from the Soulseek server: another client logged in using the username {Username}", Client.Username);
+ Log.Error("Disconnected from the Soulseek server: another client logged in using the same username");
}
else
{
Log.Error("Disconnected from the Soulseek server: {Message}", args.Exception?.Message ?? args.Message);
-
- if (string.IsNullOrEmpty(Options.Soulseek.Username) || string.IsNullOrEmpty(Options.Soulseek.Password))
- {
- Log.Warning($"Not reconnecting to the Soulseek server; username and/or password invalid. Specify valid credentials and manually connect, or update config and restart.");
- return;
- }
-
- // none of the conditions that would prevent a reconnect attempt have been met
- // update the state to set AttemptingReconnect to true, which will cause the IConnectionMonitor
- // to begin the reconnect sequence
- State.SetValue(state => state with
- {
- Server = state.Server with
- {
- AttemptingReconnect = true,
- },
- });
+ ConnectionWatchdog.Start();
}
}
@@ -503,7 +492,6 @@ namespace slskd
Address = Client.Address,
IPEndPoint = Client.IPEndPoint,
State = Client.State,
- AttemptingReconnect = Client.State.HasFlag(SoulseekClientStates.Connected) ? false : state.Server.AttemptingReconnect,
},
User = state.User with
{