aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-09-12 11:13:59 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-09-12 11:13:59 -0500
commit13cb6363985f2feb6b8f655e9894123cc22d26bd (patch)
treeb9499d3ded5facb3039fadc870c11a0e64105c68 /src
parent32b6e44f6db7a77905e45e7bbbe94f91be02fdee (diff)
downloadslskd-13cb6363985f2feb6b8f655e9894123cc22d26bd.tar.gz
remove ISoulseekClient from SearchService
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Application/Application.cs3
-rw-r--r--src/slskd/Application/IApplication.cs58
-rw-r--r--src/slskd/Application/Search/SearchService.cs13
3 files changed, 51 insertions, 23 deletions
diff --git a/src/slskd/Application/Application.cs b/src/slskd/Application/Application.cs
index 87f589f7..8a4f86ac 100644
--- a/src/slskd/Application/Application.cs
+++ b/src/slskd/Application/Application.cs
@@ -290,6 +290,9 @@ namespace slskd
public Task AddUserAsync(string username) => SoulseekClient.AddUserAsync(username);
public Task<BrowseResponse> BrowseAsync(string username) => SoulseekClient.BrowseAsync(username);
public Task<UserInfo> GetUserInfoAsync(string username) => SoulseekClient.GetUserInfoAsync(username);
+ public int GetNextToken() => SoulseekClient.GetNextToken();
+ public Task<Soulseek.Search> SearchAsync(SearchQuery query, Action<SearchResponse> responseReceived, SearchScope scope = null, int? token = null, SearchOptions options = null, CancellationToken? cancellationToken = null)
+ => SoulseekClient.SearchAsync(query, responseReceived, scope, token, options, cancellationToken);
private async Task OptionsMonitor_OnChange(Options newOptions)
{
diff --git a/src/slskd/Application/IApplication.cs b/src/slskd/Application/IApplication.cs
index 78a05151..53391e56 100644
--- a/src/slskd/Application/IApplication.cs
+++ b/src/slskd/Application/IApplication.cs
@@ -27,28 +27,54 @@ namespace slskd
public interface IApplication : IHostedService
{
+ public Task AcknowledgePrivateMessageAsync(int id);
+
+ public Task AddPrivateRoomMemberAsync(string roomName, string username);
+
+ public Task AddUserAsync(string username);
+
+ public Task<BrowseResponse> BrowseAsync(string username);
+
public Task CheckVersionAsync();
+
public Task ConnectAsync();
+
public void Disconnect(string message = null, Exception exception = null);
- public Task RescanSharesAsync();
- public Task StartPublicChatAsync();
- public Task StopPublicChatAsync();
- public Task AcknowledgePrivateMessageAsync(int id);
- public Task SendPrivateMessageAsync(string username, string message);
- public Task SendRoomMessageAsync(string roomName, string message);
- public Task SetRoomTickerAsync(string roomName, string message);
- public Task AddPrivateRoomMemberAsync(string roomName, string username);
- public Task<RoomList> GetRoomListAsync();
- public Task<RoomData> JoinRoomAsync(string roomName);
- public Task LeaveRoomAsync(string roomName);
+
public Task DownloadAsync(string username, string filename, Stream outputStream, long? size, long startOffset = 0, int? token = null, TransferOptions options = null, CancellationToken? cancellationToken = null);
+
public Task<int> GetDownloadPlaceInQueueAsync(string username, string filename);
- public Task<BrowseResponse> BrowseAsync(string username);
- public Task<UserInfo> GetUserInfoAsync(string username);
+
+ public int GetNextToken();
+
+ public Task<RoomList> GetRoomListAsync();
+
public Task<IPEndPoint> GetUserEndPointAsync(string username);
+
+ public Task<UserInfo> GetUserInfoAsync(string username);
+
+ public Task<bool> GetUserPrivilegedAsync(string username);
+
public Task<UserStatus> GetUserStatusAsync(string username);
+
public Task GrantUserPrivilegesAsync(string username, int days);
- public Task<bool> GetUserPrivilegedAsync(string username);
- public Task AddUserAsync(string username);
+
+ public Task<RoomData> JoinRoomAsync(string roomName);
+
+ public Task LeaveRoomAsync(string roomName);
+
+ public Task RescanSharesAsync();
+
+ public Task<Soulseek.Search> SearchAsync(SearchQuery query, Action<SearchResponse> responseReceived, SearchScope scope = null, int? token = null, SearchOptions options = null, CancellationToken? cancellationToken = null);
+
+ public Task SendPrivateMessageAsync(string username, string message);
+
+ public Task SendRoomMessageAsync(string roomName, string message);
+
+ public Task SetRoomTickerAsync(string roomName, string message);
+
+ public Task StartPublicChatAsync();
+
+ public Task StopPublicChatAsync();
}
-}
+} \ No newline at end of file
diff --git a/src/slskd/Application/Search/SearchService.cs b/src/slskd/Application/Search/SearchService.cs
index 8de18977..ba1254a4 100644
--- a/src/slskd/Application/Search/SearchService.cs
+++ b/src/slskd/Application/Search/SearchService.cs
@@ -28,7 +28,6 @@ namespace slskd.Search
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
- using ISoulseekClient = Soulseek.ISoulseekClient;
using SearchOptions = Soulseek.SearchOptions;
using SearchQuery = Soulseek.SearchQuery;
using SearchScope = Soulseek.SearchScope;
@@ -44,17 +43,17 @@ namespace slskd.Search
/// Initializes a new instance of the <see cref="SearchService"/> class.
/// </summary>
/// <param name="optionsMonitor"></param>
- /// <param name="client">The client instance to use.</param>
+ /// <param name="application"></param>
/// <param name="contextFactory">The database context to use.</param>
/// <param name="log">The logger.</param>
public SearchService(
IOptionsMonitor<Options> optionsMonitor,
- ISoulseekClient client,
+ IApplication application,
IDbContextFactory<SearchDbContext> contextFactory,
ILogger<SearchService> log)
{
OptionsMonitor = optionsMonitor;
- Client = client;
+ Application = application;
ContextFactory = contextFactory;
Log = log;
}
@@ -63,7 +62,7 @@ namespace slskd.Search
= new ConcurrentDictionary<Guid, CancellationTokenSource>();
private IOptionsMonitor<Options> OptionsMonitor { get; }
- private ISoulseekClient Client { get; }
+ private IApplication Application { get; }
private IDbContextFactory<SearchDbContext> ContextFactory { get; }
private ILogger<SearchService> Log { get; set; }
@@ -77,7 +76,7 @@ namespace slskd.Search
/// <returns>The completed search.</returns>
public async Task<Search> CreateAsync(Guid id, SearchQuery query, SearchScope scope, SearchOptions options = null)
{
- var token = Client.GetNextToken();
+ var token = Application.GetNextToken();
var cancellationTokenSource = new CancellationTokenSource();
var search = new Search()
@@ -104,7 +103,7 @@ namespace slskd.Search
CancellationTokens.TryAdd(id, cancellationTokenSource);
var responses = new List<Response>();
- var soulseekSearch = await Client.SearchAsync(
+ var soulseekSearch = await Application.SearchAsync(
query,
responseReceived: (response) =>
{