using System.Threading; using System.Threading.Tasks; using Grpc.Core; namespace INetMock.Client.Audit.Serialization { public sealed class EventServerStreamReader : IProtoEventReader { private readonly AsyncServerStreamingCall _asyncEventStream; public EventServerStreamReader(AsyncServerStreamingCall asyncEventStream) { _asyncEventStream = asyncEventStream; } public async Task ReadAsync(CancellationToken token = default) { if (!await _asyncEventStream.ResponseStream.MoveNext(token)) return null; return _asyncEventStream.ResponseStream.Current; } public void Dispose() => _asyncEventStream.Dispose(); public ValueTask DisposeAsync() { _asyncEventStream.Dispose(); return ValueTask.CompletedTask; } } }