aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application/Management/ManagementService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-07-24 14:39:40 -0500
committerGitHub <noreply@github.com>2021-07-24 14:39:40 -0500
commit58bc401dab5d7eb3bc6cb07a22e0ee9c97ddf4bd (patch)
tree64072f5eaa896335cc04de8ffe84fa79a50a2be7 /src/slskd/Application/Management/ManagementService.cs
parentfc7800409dfbe0cf26a72dd1de17cbae23d0cb35 (diff)
parent78b3b953d9c36c2cc2939ad00881b0cbf388865a (diff)
downloadslskd-58bc401dab5d7eb3bc6cb07a22e0ee9c97ddf4bd.tar.gz
Merge pull request #125 from slskd/options
Refactor configuration components to allow for run-time updates
Diffstat (limited to 'src/slskd/Application/Management/ManagementService.cs')
-rw-r--r--src/slskd/Application/Management/ManagementService.cs25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/slskd/Application/Management/ManagementService.cs b/src/slskd/Application/Management/ManagementService.cs
index 84935879..66ed2b97 100644
--- a/src/slskd/Application/Management/ManagementService.cs
+++ b/src/slskd/Application/Management/ManagementService.cs
@@ -15,6 +15,8 @@
// along with this program. If not, see https://www.gnu.org/licenses/.
// </copyright>
+using Microsoft.Extensions.Options;
+
namespace slskd.Management
{
using System;
@@ -32,15 +34,23 @@ namespace slskd.Management
/// <param name="optionsMonitor">The options monitor used to derive application options.</param>
/// <param name="soulseekClient">The Soulseek client.</param>
public ManagementService(
- Microsoft.Extensions.Options.IOptionsMonitor<Options> optionsMonitor,
+ IOptionsMonitor<Options> optionsMonitor,
ISoulseekClient soulseekClient)
{
- Options = optionsMonitor.CurrentValue;
+ OptionsMonitor = optionsMonitor;
Client = soulseekClient;
}
private ISoulseekClient Client { get; }
- private Options Options { get; }
+ private Options Options => OptionsMonitor.CurrentValue;
+ private IOptionsMonitor<Options> OptionsMonitor { get; }
+
+ /// <summary>
+ /// Connects the Soulseek client to the server using the configured username and password.
+ /// </summary>
+ /// <returns>The operation context.</returns>
+ public Task ConnectServerAsync()
+ => Client.ConnectAsync(Options.Soulseek.Username, Options.Soulseek.Password);
/// <summary>
/// Disconnects the Soulseek client from the server.
@@ -51,13 +61,6 @@ namespace slskd.Management
=> Client.Disconnect(message, exception ?? new IntentionalDisconnectException(message));
/// <summary>
- /// Connects the Soulseek client to the server using the configured username and password.
- /// </summary>
- /// <returns>The operation context.</returns>
- public Task ConnectServerAsync()
- => Client.ConnectAsync(Options.Soulseek.Username, Options.Soulseek.Password);
-
- /// <summary>
/// Gets the current state of the connection to the Soulseek server.
/// </summary>
/// <returns>The current server state.</returns>
@@ -70,4 +73,4 @@ namespace slskd.Management
Username = Client.Username,
};
}
-}
+} \ No newline at end of file