public static async ValueTask <long> ReceiveAsync(this ITransportChannel channel, Stream content, long length) { var result = await channel.TryReceiveAsync(content).ConfigureAwait(false); if (!result.HasValue) { throw new OperationCanceledException(); } return(result.Value); }
public static async Task <byte[]> ReceiveMessageAsync( this ITransportChannel channel) { using (var stream = new MemoryStream()) { await channel.TryReceiveAsync(stream).ConfigureAwait(false); return(stream.ToArray()); } }
public static async ValueTask <Maybe <long> > ReceiveMessageAsync( this ITransportChannel channel, byte[] buffer, int offset, int count) { using (var stream = new MemoryStream(buffer, offset, count, writable: true)) { return(await channel.TryReceiveAsync(stream).ConfigureAwait(false)); } }
public static async Task <Maybe <byte[]> > TryReceiveMessageAsync( this ITransportChannel channel) { using (var stream = new MemoryStream()) { var result = await channel.TryReceiveAsync(stream).ConfigureAwait(false); if (!result.HasValue) { return(Nothing.Instance); } return(stream.ToArray()); } }