aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-09-05 12:37:06 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-09-05 12:37:06 -0500
commitb2b4343a9fa973d16e9de14dd467737fc0b0a706 (patch)
tree03d15ddab8ec1b097ff275009294ab3189423bc5 /src
parentabe489187e0ef051a535ec25431a5306ccf07e98 (diff)
downloadslskd-b2b4343a9fa973d16e9de14dd467737fc0b0a706.tar.gz
automatically join configured rooms on connect
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Application/Application.cs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/slskd/Application/Application.cs b/src/slskd/Application/Application.cs
index 3e054dc8..f7488ef3 100644
--- a/src/slskd/Application/Application.cs
+++ b/src/slskd/Application/Application.cs
@@ -425,6 +425,17 @@ namespace slskd
// send whatever counts we have currently. we'll probably connect before the cache is primed,
// so these will be zero initially, but we'll update them when the cache is filled.
_ = SoulseekClient.SetSharedCountsAsync(State.SharedFileCache.Directories, State.SharedFileCache.Files);
+ _ = AutoJoinRooms(OptionsMonitor.CurrentValue.Rooms);
+ }
+
+ private Task AutoJoinRooms(string[] rooms)
+ {
+ Logger.Information("Joining rooms {Rooms}", string.Join(", ", OptionsMonitor.CurrentValue.Rooms));
+
+ var tasks = rooms.Select(room => SoulseekClient.JoinRoomAsync(room)
+ .ContinueWith(task => Logger.Warning("Failed to join room {Room}: {Message}", room, task.Exception.InnerExceptions.First().Message), TaskContinuationOptions.OnlyOnFaulted));
+
+ return Task.WhenAll(tasks);
}
private async void Client_Disconnected(object sender, SoulseekClientDisconnectedEventArgs args)