Lawo.EmberPlusSharp.S101.MessageEncodingStream.WriteAsync C# (CSharp) Method

WriteAsync() public final method

public final WriteAsync ( byte buffer, int offset, int count, CancellationToken cancellationToken ) : Task
buffer byte
offset int
count int
cancellationToken System.Threading.CancellationToken
return Task
        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;
            }
        }