public sealed override async Task WriteAsync(
byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
this.AssertNotDisposed();
BufferHelper.AssertValidRange(buffer, "buffer", offset, "offset", count, "count");
while (count > 0)
{
if (this.framingStream.TotalCount >= MaxFrameLength)
{
await this.DisposeAndCreateFramingStreamAsync(PacketFlags.None, cancellationToken);
}
var countToWrite = Math.Min(count, MaxFrameLength - this.framingStream.TotalCount);
await this.unframedBuffer.WriteAsync(buffer, offset, countToWrite, cancellationToken);
offset += countToWrite;
count -= countToWrite;
}
}