Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Added abstract NntpClient class.

nzbdav-dev78d0e65c9bca
diff --git a/backend/Clients/Usenet/BaseNntpClient.cs b/backend/Clients/Usenet/BaseNntpClient.cs
index aba50334..ccb99cc1 100644
--- a/backend/Clients/Usenet/BaseNntpClient.cs
+++ b/backend/Clients/Usenet/BaseNntpClient.cs
@@ -13,11 +13,11 @@ namespace NzbWebDAV.Clients.Usenet;
/// 3. Provide yenc-decoded data for articles retrieved through article/body commands.
/// 4. throw `UsenetArticleNotFound` when articles do not exist, within article/body/head commands.
/// </summary>
-public class BaseNntpClient : INntpClient
+public class BaseNntpClient : NntpClient
{
private readonly UsenetClient _client = new();
- public async Task ConnectAsync(string host, int port, bool useSsl, CancellationToken cancellationToken)
+ public override async Task ConnectAsync(string host, int port, bool useSsl, CancellationToken cancellationToken)
{
try
{
@@ -30,7 +30,12 @@ public class BaseNntpClient : INntpClient
}
}
- public async Task<UsenetResponse> AuthenticateAsync(string user, string pass, CancellationToken cancellationToken)
+ public override async Task<UsenetResponse> AuthenticateAsync
+ (
+ string user,
+ string pass,
+ CancellationToken cancellationToken
+ )
{
try
{
@@ -49,12 +54,12 @@ public class BaseNntpClient : INntpClient
}
}
- public Task<UsenetStatResponse> StatAsync(SegmentId segmentId, CancellationToken cancellationToken)
+ public override Task<UsenetStatResponse> StatAsync(SegmentId segmentId, CancellationToken cancellationToken)
{
return _client.StatAsync(segmentId, cancellationToken);
}
- public async Task<UsenetHeadResponse> HeadAsync(SegmentId segmentId, CancellationToken cancellationToken)
+ public override async Task<UsenetHeadResponse> HeadAsync(SegmentId segmentId, CancellationToken cancellationToken)
{
var headResponse = await _client.HeadAsync(segmentId, cancellationToken);
@@ -70,7 +75,7 @@ public class BaseNntpClient : INntpClient
};
}
- public Task<UsenetDecodedBodyResponse> DecodedBodyAsync
+ public override Task<UsenetDecodedBodyResponse> DecodedBodyAsync
(
SegmentId segmentId,
CancellationToken cancellationToken
@@ -79,7 +84,7 @@ public class BaseNntpClient : INntpClient
return DecodedBodyAsync(segmentId, onConnectionReadyAgain: null, cancellationToken);
}
- public async Task<UsenetDecodedBodyResponse> DecodedBodyAsync
+ public override async Task<UsenetDecodedBodyResponse> DecodedBodyAsync
(
SegmentId segmentId,
Action<ArticleBodyResult>? onConnectionReadyAgain,
@@ -100,7 +105,7 @@ public class BaseNntpClient : INntpClient
};
}
- public Task<UsenetDecodedArticleResponse> DecodedArticleAsync
+ public override Task<UsenetDecodedArticleResponse> DecodedArticleAsync
(
SegmentId segmentId,
CancellationToken cancellationToken
@@ -109,7 +114,7 @@ public class BaseNntpClient : INntpClient
return DecodedArticleAsync(segmentId, onConnectionReadyAgain: null, cancellationToken);
}
- public async Task<UsenetDecodedArticleResponse> DecodedArticleAsync
+ public override async Task<UsenetDecodedArticleResponse> DecodedArticleAsync
(
SegmentId segmentId,
Action<ArticleBodyResult>? onConnectionReadyAgain,
@@ -131,17 +136,12 @@ public class BaseNntpClient : INntpClient
};
}
- public Task<UsenetDateResponse> DateAsync(CancellationToken cancellationToken)
+ public override Task<UsenetDateResponse> DateAsync(CancellationToken cancellationToken)
{
return _client.DateAsync(cancellationToken);
}
- public Task WaitForReadyAsync(CancellationToken cancellationToken)
- {
- return _client.WaitForReadyAsync(cancellationToken);
- }
-
- public void Dispose()
+ public override void Dispose()
{
_client.Dispose();
GC.SuppressFinalize(this);
diff --git a/backend/Clients/Usenet/INntpClient.cs b/backend/Clients/Usenet/INntpClient.cs
index 1eeed97a..0ba2cae5 100644
--- a/backend/Clients/Usenet/INntpClient.cs
+++ b/backend/Clients/Usenet/INntpClient.cs
@@ -1,6 +1,4 @@
using NzbWebDAV.Clients.Usenet.Models;
-using NzbWebDAV.Exceptions;
-using NzbWebDAV.Extensions;
using NzbWebDAV.Streams;
using Usenet.Nzb;
using UsenetSharp.Models;
@@ -9,6 +7,7 @@ namespace NzbWebDAV.Clients.Usenet;
public interface INntpClient : IDisposable
{
+ // core methods
Task ConnectAsync(
string host, int port, bool useSsl, CancellationToken cancellationToken);
@@ -36,63 +35,22 @@ public interface INntpClient : IDisposable
Task<UsenetDateResponse> DateAsync(
CancellationToken cancellationToken);
- public async Task<UsenetYencHeader> GetYencHeadersAsync(string segmentId, CancellationToken ct)
- {
- var decodedBodyResponse = await DecodedBodyAsync(segmentId, ct).ConfigureAwait(false);
- await using var stream = decodedBodyResponse.Stream;
- var headers = await stream.GetYencHeadersAsync(ct).ConfigureAwait(false);
- return headers!;
- }
-
- public async Task<long> GetFileSizeAsync(NzbFile file, CancellationToken ct)
- {
- if (file.Segments.Count == 0) return 0;
- var headers = await GetYencHeadersAsync(file.Segments[^1].MessageId.Value, ct).ConfigureAwait(false);
- return headers!.PartOffset + headers!.PartSize;
- }
-
- public async Task<NzbFileStream> GetFileStream(NzbFile nzbFile, int concurrentConnections, CancellationToken ct)
- {
- var segmentIds = nzbFile.GetSegmentIds();
- var fileSize = await GetFileSizeAsync(nzbFile, ct).ConfigureAwait(false);
- return new NzbFileStream(segmentIds, fileSize, this, concurrentConnections);
- }
-
- public NzbFileStream GetFileStream(NzbFile nzbFile, long fileSize, int concurrentConnections)
- {
- return new NzbFileStream(nzbFile.GetSegmentIds(), fileSize, this, concurrentConnections);
- }
-
- public NzbFileStream GetFileStream(string[] segmentIds, long fileSize, int concurrentConnections)
- {
- return new NzbFileStream(segmentIds, fileSize, this, concurrentConnections);
- }
-
- public async Task CheckAllSegmentsAsync
- (
- IEnumerable<string> segmentIds,
- int concurrency,
- IProgress<int>? progress,
- CancellationToken cancellationToken
- )
- {
- using var childCt = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
- var token = childCt.Token;
-
- var tasks = segmentIds
- .Select(async segmentId => (
- SegmentId: segmentId,
- Result: await StatAsync(segmentId, token).ConfigureAwait(false)
- ))
- .WithConcurrencyAsync(concurrency);
-
- var processed = 0;
- await foreach (var task in tasks.ConfigureAwait(false))
- {
- progress?.Report(++processed);
- if (task.Result.ResponseType == UsenetResponseType.ArticleExists) continue;
- await childCt.CancelAsync().ConfigureAwait(false);
- throw new UsenetArticleNotFoundException(task.SegmentId);
- }
- }
+ // helpers
+ Task<UsenetYencHeader> GetYencHeadersAsync(
+ string segmentId, CancellationToken ct);
+
+ Task<long> GetFileSizeAsync(
+ NzbFile file, CancellationToken ct);
+
+ Task<NzbFileStream> GetFileStream(
+ NzbFile nzbFile, int concurrentConnections, CancellationToken ct);
+
+ NzbFileStream GetFileStream(
+ NzbFile nzbFile, long fileSize, int concurrentConnections);
+
+ NzbFileStream GetFileStream(
+ string[] segmentIds, long fileSize, int concurrentConnections);
+
+ Task CheckAllSegmentsAsync(
+ IEnumerable<string> segmentIds, int concurrency, IProgress<int>? progress, CancellationToken cancellationToken);
}
\ No newline at end of file
diff --git a/backend/Clients/Usenet/MultiConnectionNntpClient.cs b/backend/Clients/Usenet/MultiConnectionNntpClient.cs
index a53d960b..18882b85 100644
--- a/backend/Clients/Usenet/MultiConnectionNntpClient.cs
+++ b/backend/Clients/Usenet/MultiConnectionNntpClient.cs
@@ -16,8 +16,7 @@ namespace NzbWebDAV.Clients.Usenet;
/// </summary>
/// <param name="connectionPool"></param>
/// <param name="type"></param>
-public class MultiConnectionNntpClient(ConnectionPool<INntpClient> connectionPool, ProviderType type)
- : INntpClient
+public class MultiConnectionNntpClient(ConnectionPool<INntpClient> connectionPool, ProviderType type) : NntpClient
{
public ProviderType ProviderType { get; } = type;
public int LiveConnections => connectionPool.LiveConnections;
@@ -25,31 +24,31 @@ public class MultiConnectionNntpClient(ConnectionPool<INntpClient> connectionPoo
public int ActiveConnections => connectionPool.ActiveConnections;
public int AvailableConnections => connectionPool.AvailableConnections;
- public Task ConnectAsync(string host, int port, bool useSsl, CancellationToken cancellationToken)
+ public override Task ConnectAsync(string host, int port, bool useSsl, CancellationToken cancellationToken)
{
throw new NotSupportedException("Please connect within the connectionFactory");
}
- public Task<UsenetResponse> AuthenticateAsync(string user, string pass, CancellationToken cancellationToken)
+ public override Task<UsenetResponse> AuthenticateAsync(string user, string pass, CancellationToken cancellationToken)
{
throw new NotSupportedException("Please authenticate within the connectionFactory");
}
- public async Task<UsenetStatResponse> StatAsync(SegmentId segmentId, CancellationToken ct)
+ public override async Task<UsenetStatResponse> StatAsync(SegmentId segmentId, CancellationToken ct)
{
const SemaphorePriority priority = SemaphorePriority.Low;
using var connectionLock = await connectionPool.GetConnectionLockAsync(priority, ct).ConfigureAwait(false);
return await connectionLock.Connection.StatAsync(segmentId, ct).ConfigureAwait(false);
}
- public async Task<UsenetHeadResponse> HeadAsync(SegmentId segmentId, CancellationToken ct)
+ public override async Task<UsenetHeadResponse> HeadAsync(SegmentId segmentId, CancellationToken ct)
{
const SemaphorePriority priority = SemaphorePriority.Low;
using var connectionLock = await connectionPool.GetConnectionLockAsync(priority, ct).ConfigureAwait(false);
return await connectionLock.Connection.HeadAsync(segmentId, ct).ConfigureAwait(false);
}
- public async Task<UsenetDecodedBodyResponse> DecodedBodyAsync(SegmentId segmentId, CancellationToken ct)
+ public override async Task<UsenetDecodedBodyResponse> DecodedBodyAsync(SegmentId segmentId, CancellationToken ct)
{
const SemaphorePriority priority = SemaphorePriority.High;
var connectionLock = await connectionPool.GetConnectionLockAsync(priority, ct).ConfigureAwait(false);
@@ -61,7 +60,11 @@ public class MultiConnectionNntpClient(ConnectionPool<INntpClient> connectionPoo
}
}
- public async Task<UsenetDecodedArticleResponse> DecodedArticleAsync(SegmentId segmentId, CancellationToken ct)
+ public override async Task<UsenetDecodedArticleResponse> DecodedArticleAsync
+ (
+ SegmentId segmentId,
+ CancellationToken ct
+ )
{
const SemaphorePriority priority = SemaphorePriority.High;
var connectionLock = await connectionPool.GetConnectionLockAsync(priority, ct).ConfigureAwait(false);
@@ -73,14 +76,14 @@ public class MultiConnectionNntpClient(ConnectionPool<INntpClient> connectionPoo
}
}
- public async Task<UsenetDateResponse> DateAsync(CancellationToken ct)
+ public override async Task<UsenetDateResponse> DateAsync(CancellationToken ct)
{
const SemaphorePriority priority = SemaphorePriority.Low;
using var connectionLock = await connectionPool.GetConnectionLockAsync(priority, ct).ConfigureAwait(false);
return await connectionLock.Connection.DateAsync(ct).ConfigureAwait(false);
}
- public async Task<UsenetDecodedBodyResponse> DecodedBodyAsync
+ public override async Task<UsenetDecodedBodyResponse> DecodedBodyAsync
(
SegmentId segmentId,
Action<ArticleBodyResult>? onConnectionReadyAgain,
@@ -98,7 +101,7 @@ public class MultiConnectionNntpClient(ConnectionPool<INntpClient> connectionPoo
}
}
- public async Task<UsenetDecodedArticleResponse> DecodedArticleAsync
+ public override async Task<UsenetDecodedArticleResponse> DecodedArticleAsync
(
SegmentId segmentId,
Action<ArticleBodyResult>? onConnectionReadyAgain,
@@ -116,15 +119,7 @@ public class MultiConnectionNntpClient(ConnectionPool<INntpClient> connectionPoo
}
}
- public async Task<UsenetYencHeader> GetYencHeadersAsync(string segmentId, CancellationToken ct)
- {
- var decodedBodyResponse = await DecodedBodyAsync(segmentId, ct).ConfigureAwait(false);
- await using var stream = decodedBodyResponse.Stream;
- var headers = await stream.GetYencHeadersAsync(ct).ConfigureAwait(false);
- return headers!;
- }
-
- public void Dispose()
+ public override void Dispose()
{
connectionPool.Dispose();
GC.SuppressFinalize(this);
diff --git a/backend/Clients/Usenet/MultiProviderNntpClient.cs b/backend/Clients/Usenet/MultiProviderNntpClient.cs
index 8667093c..54033661 100644
--- a/backend/Clients/Usenet/MultiProviderNntpClient.cs
+++ b/backend/Clients/Usenet/MultiProviderNntpClient.cs
@@ -6,34 +6,38 @@ using UsenetSharp.Models;
namespace NzbWebDAV.Clients.Usenet;
-public class MultiProviderNntpClient(List<MultiConnectionNntpClient> providers) : INntpClient
+public class MultiProviderNntpClient(List<MultiConnectionNntpClient> providers) : NntpClient
{
- public Task ConnectAsync(string host, int port, bool useSsl, CancellationToken cancellationToken)
+ public override Task ConnectAsync(string host, int port, bool useSsl, CancellationToken ct)
{
throw new NotSupportedException("Please connect within the connectionFactory");
}
- public Task<UsenetResponse> AuthenticateAsync(string user, string pass, CancellationToken cancellationToken)
+ public override Task<UsenetResponse> AuthenticateAsync(string user, string pass, CancellationToken ct)
{
throw new NotSupportedException("Please authenticate within the connectionFactory");
}
- public Task<UsenetStatResponse> StatAsync(SegmentId segmentId, CancellationToken cancellationToken)
+ public override Task<UsenetStatResponse> StatAsync(SegmentId segmentId, CancellationToken cancellationToken)
{
return RunFromPoolWithBackup(x => x.StatAsync(segmentId, cancellationToken), cancellationToken);
}
- public Task<UsenetHeadResponse> HeadAsync(SegmentId segmentId, CancellationToken cancellationToken)
+ public override Task<UsenetHeadResponse> HeadAsync(SegmentId segmentId, CancellationToken cancellationToken)
{
return RunFromPoolWithBackup(x => x.HeadAsync(segmentId, cancellationToken), cancellationToken);
}
- public Task<UsenetDecodedBodyResponse> DecodedBodyAsync(SegmentId segmentId, CancellationToken cancellationToken)
+ public override Task<UsenetDecodedBodyResponse> DecodedBodyAsync
+ (
+ SegmentId segmentId,
+ CancellationToken cancellationToken
+ )
{
return RunFromPoolWithBackup(x => x.DecodedBodyAsync(segmentId, cancellationToken), cancellationToken);
}
- public Task<UsenetDecodedArticleResponse> DecodedArticleAsync
+ public override Task<UsenetDecodedArticleResponse> DecodedArticleAsync
(
SegmentId segmentId,
CancellationToken cancellationToken
@@ -42,12 +46,12 @@ public class MultiProviderNntpClient(List<MultiConnectionNntpClient> providers)
return RunFromPoolWithBackup(x => x.DecodedArticleAsync(segmentId, cancellationToken), cancellationToken);
}
- public Task<UsenetDateResponse> DateAsync(CancellationToken cancellationToken)
+ public override Task<UsenetDateResponse> DateAsync(CancellationToken cancellationToken)
{
return RunFromPoolWithBackup(x => x.DateAsync(cancellationToken), cancellationToken);
}
- public async Task<UsenetDecodedBodyResponse> DecodedBodyAsync
+ public override async Task<UsenetDecodedBodyResponse> DecodedBodyAsync
(
SegmentId segmentId,
Action<ArticleBodyResult>? onConnectionReadyAgain,
@@ -80,7 +84,7 @@ public class MultiProviderNntpClient(List<MultiConnectionNntpClient> providers)
}
}
- public async Task<UsenetDecodedArticleResponse> DecodedArticleAsync
+ public override async Task<UsenetDecodedArticleResponse> DecodedArticleAsync
(
SegmentId segmentId,
Action<ArticleBodyResult>? onConnectionReadyAgain,
@@ -113,11 +117,6 @@ public class MultiProviderNntpClient(List<MultiConnectionNntpClient> providers)
}
}
- public Task WaitForReadyAsync(CancellationToken cancellationToken)
- {
- throw new NotSupportedException();
- }
-
private async Task<T> RunFromPoolWithBackup<T>
(
Func<INntpClient, Task<T>> task,
@@ -167,7 +166,7 @@ public class MultiProviderNntpClient(List<MultiConnectionNntpClient> providers)
.ToList();
}
- public void Dispose()
+ public override void Dispose()
{
foreach (var provider in providers)
provider.Dispose();
diff --git a/backend/Clients/Usenet/NntpClient.cs b/backend/Clients/Usenet/NntpClient.cs
new file mode 100644
index 00000000..e164808e
--- /dev/null
+++ b/backend/Clients/Usenet/NntpClient.cs
@@ -0,0 +1,103 @@
+using NzbWebDAV.Clients.Usenet.Models;
+using NzbWebDAV.Exceptions;
+using NzbWebDAV.Extensions;
+using NzbWebDAV.Streams;
+using Usenet.Nzb;
+using UsenetSharp.Models;
+
+namespace NzbWebDAV.Clients.Usenet;
+
+/// <summary>
+/// Abstract base class for NNTP clients with default implementations of utility methods.
+/// </summary>
+public abstract class NntpClient : INntpClient
+{
+ public abstract Task ConnectAsync(
+ string host, int port, bool useSsl, CancellationToken cancellationToken);
+
+ public abstract Task<UsenetResponse> AuthenticateAsync(
+ string user, string pass, CancellationToken cancellationToken);
+
+ public abstract Task<UsenetStatResponse> StatAsync(
+ SegmentId segmentId, CancellationToken cancellationToken);
+
+ public abstract Task<UsenetHeadResponse> HeadAsync(
+ SegmentId segmentId, CancellationToken cancellationToken);
+
+ public abstract Task<UsenetDecodedBodyResponse> DecodedBodyAsync(
+ SegmentId segmentId, CancellationToken cancellationToken);
+
+ public abstract Task<UsenetDecodedBodyResponse> DecodedBodyAsync(
+ SegmentId segmentId, Action<ArticleBodyResult>? onConnectionReadyAgain, CancellationToken cancellationToken);
+
+ public abstract Task<UsenetDecodedArticleResponse> DecodedArticleAsync(
+ SegmentId segmentId, CancellationToken cancellationToken);
+
+ public abstract Task<UsenetDecodedArticleResponse> DecodedArticleAsync(
+ SegmentId segmentId, Action<ArticleBodyResult>? onConnectionReadyAgain, CancellationToken cancellationToken);
+
+ public abstract Task<UsenetDateResponse> DateAsync(
+ CancellationToken cancellationToken);
+
+ public abstract void Dispose();
+
+ public virtual async Task<UsenetYencHeader> GetYencHeadersAsync(string segmentId, CancellationToken ct)
+ {
+ var decodedBodyResponse = await DecodedBodyAsync(segmentId, ct).ConfigureAwait(false);
+ await using var stream = decodedBodyResponse.Stream;
+ var headers = await stream.GetYencHeadersAsync(ct).ConfigureAwait(false);
+ return headers!;
+ }
+
+ public virtual async Task<long> GetFileSizeAsync(NzbFile file, CancellationToken ct)
+ {
+ if (file.Segments.Count == 0) return 0;
+ var headers = await GetYencHeadersAsync(file.Segments[^1].MessageId.Value, ct).ConfigureAwait(false);
+ return headers!.PartOffset + headers!.PartSize;
+ }
+
+ public virtual async Task<NzbFileStream> GetFileStream(NzbFile nzbFile, int concurrency, CancellationToken ct)
+ {
+ var segmentIds = nzbFile.GetSegmentIds();
+ var fileSize = await GetFileSizeAsync(nzbFile, ct).ConfigureAwait(false);
+ return new NzbFileStream(segmentIds, fileSize, this, concurrency);
+ }
+
+ public virtual NzbFileStream GetFileStream(NzbFile nzbFile, long fileSize, int concurrency)
+ {
+ return new NzbFileStream(nzbFile.GetSegmentIds(), fileSize, this, concurrency);
+ }
+
+ public virtual NzbFileStream GetFileStream(string[] segmentIds, long fileSize, int concurrency)
+ {
+ return new NzbFileStream(segmentIds, fileSize, this, concurrency);
+ }
+
+ public virtual async Task CheckAllSegmentsAsync
+ (
+ IEnumerable<string> segmentIds,
+ int concurrency,
+ IProgress<int>? progress,
+ CancellationToken cancellationToken
+ )
+ {
+ using var childCt = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
+ var token = childCt.Token;
+
+ var tasks = segmentIds
+ .Select(async segmentId => (
+ SegmentId: segmentId,
+ Result: await StatAsync(segmentId, token).ConfigureAwait(false)
+ ))
+ .WithConcurrencyAsync(concurrency);
+
+ var processed = 0;
+ await foreach (var task in tasks.ConfigureAwait(false))
+ {
+ progress?.Report(++processed);
+ if (task.Result.ResponseType == UsenetResponseType.ArticleExists) continue;
+ await childCt.CancelAsync().ConfigureAwait(false);
+ throw new UsenetArticleNotFoundException(task.SegmentId);
+ }
+ }
+}
diff --git a/backend/Clients/Usenet/WrappingNntpClient.cs b/backend/Clients/Usenet/WrappingNntpClient.cs
index 72c6ad5d..5f860508 100644
--- a/backend/Clients/Usenet/WrappingNntpClient.cs
+++ b/backend/Clients/Usenet/WrappingNntpClient.cs
@@ -3,57 +3,46 @@ using UsenetSharp.Models;
namespace NzbWebDAV.Clients.Usenet;
-public class WrappingNntpClient(INntpClient usenetClient) : INntpClient
+public class WrappingNntpClient(INntpClient usenetClient) : NntpClient
{
private INntpClient _usenetClient = usenetClient;
- public virtual Task ConnectAsync(string host, int port, bool useSsl, CancellationToken cancellationToken)
- {
- return _usenetClient.ConnectAsync(host, port, useSsl, cancellationToken);
- }
+ public override Task ConnectAsync(
+ string host, int port, bool useSsl, CancellationToken cancellationToken) =>
+ _usenetClient.ConnectAsync(host, port, useSsl, cancellationToken);
- public virtual Task<UsenetResponse> AuthenticateAsync(string user, string pass, CancellationToken cancellationToken)
- {
- return _usenetClient.AuthenticateAsync(user, pass, cancellationToken);
- }
+ public override Task<UsenetResponse> AuthenticateAsync(
+ string user, string pass, CancellationToken cancellationToken) =>
+ _usenetClient.AuthenticateAsync(user, pass, cancellationToken);
- public virtual Task<UsenetStatResponse> StatAsync(SegmentId segmentId, CancellationToken cancellationToken)
- {
- return _usenetClient.StatAsync(segmentId, cancellationToken);
- }
+ public override Task<UsenetStatResponse> StatAsync(
+ SegmentId segmentId, CancellationToken cancellationToken) =>
+ _usenetClient.StatAsync(segmentId, cancellationToken);
- public virtual Task<UsenetHeadResponse> HeadAsync(SegmentId segmentId, CancellationToken cancellationToken)
- {
- return _usenetClient.HeadAsync(segmentId, cancellationToken);
- }
+ public override Task<UsenetHeadResponse> HeadAsync(
+ SegmentId segmentId, CancellationToken cancellationToken) =>
+ _usenetClient.HeadAsync(segmentId, cancellationToken);
- public virtual Task<UsenetDecodedBodyResponse> DecodedBodyAsync(SegmentId segmentId, CancellationToken cancellationToken)
- {
- return _usenetClient.DecodedBodyAsync(segmentId, cancellationToken);
- }
+ public override Task<UsenetDecodedBodyResponse> DecodedBodyAsync(
+ SegmentId segmentId, CancellationToken cancellationToken) =>
+ _usenetClient.DecodedBodyAsync(segmentId, cancellationToken);
- public virtual Task<UsenetDecodedArticleResponse> DecodedArticleAsync(SegmentId segmentId,
- CancellationToken cancellationToken)
- {
- return _usenetClient.DecodedArticleAsync(segmentId, cancellationToken);
- }
+ public override Task<UsenetDecodedArticleResponse> DecodedArticleAsync(
+ SegmentId segmentId, CancellationToken cancellationToken) =>
+ _usenetClient.DecodedArticleAsync(segmentId, cancellationToken);
- public virtual Task<UsenetDateResponse> DateAsync(CancellationToken cancellationToken)
- {
- return _usenetClient.DateAsync(cancellationToken);
- }
+ public override Task<UsenetDateResponse> DateAsync(
+ CancellationToken cancellationToken) =>
+ _usenetClient.DateAsync(cancellationToken);
- public virtual Task<UsenetDecodedBodyResponse> DecodedBodyAsync(SegmentId segmentId,
- Action<ArticleBodyResult>? onConnectionReadyAgain, CancellationToken cancellationToken)
- {
- return _usenetClient.DecodedBodyAsync(segmentId, onConnectionReadyAgain, cancellationToken);
- }
+ public override Task<UsenetDecodedBodyResponse> DecodedBodyAsync(
+ SegmentId segmentId, Action<ArticleBodyResult>? onConnectionReadyAgain, CancellationToken cancellationToken) =>
+ _usenetClient.DecodedBodyAsync(segmentId, onConnectionReadyAgain, cancellationToken);
+
+ public override Task<UsenetDecodedArticleResponse> DecodedArticleAsync(
+ SegmentId segmentId, Action<ArticleBodyResult>? onConnectionReadyAgain, CancellationToken cancellationToken) =>
+ _usenetClient.DecodedArticleAsync(segmentId, onConnectionReadyAgain, cancellationToken);
- public virtual Task<UsenetDecodedArticleResponse> DecodedArticleAsync(SegmentId segmentId,
- Action<ArticleBodyResult>? onConnectionReadyAgain, CancellationToken cancellationToken)
- {
- return _usenetClient.DecodedArticleAsync(segmentId, onConnectionReadyAgain, cancellationToken);
- }
protected void ReplaceUnderlyingClient(INntpClient usenetClient)
{
@@ -63,7 +52,7 @@ public class WrappingNntpClient(INntpClient usenetClient) : INntpClient
disposable.Dispose();
}
- public virtual void Dispose()
+ public override void Dispose()
{
_usenetClient.Dispose();
GC.SuppressFinalize(this);