24 lines
597 B
C#
24 lines
597 B
C#
using Flypaper.Core.Abstractions;
|
|
using Flypaper.Core.Models;
|
|
|
|
namespace Flypaper.Core.Runtime;
|
|
|
|
internal sealed class CountingTrapChannel(ITrapChannel inner) : ITrapChannel
|
|
{
|
|
private long _bytesSent;
|
|
|
|
public TrapSession Session => inner.Session;
|
|
|
|
public string? Path => inner.Path;
|
|
|
|
public string? Host => inner.Host;
|
|
|
|
public long BytesSent => Interlocked.Read(ref _bytesSent);
|
|
|
|
public async ValueTask WriteAsync(ReadOnlyMemory<byte> data, CancellationToken ct)
|
|
{
|
|
await inner.WriteAsync(data, ct);
|
|
Interlocked.Add(ref _bytesSent, data.Length);
|
|
}
|
|
}
|