vtortola.WebSockets.Rfc6455.WebSocketMessageWriteRfc6455Stream.WriteAsync C# (CSharp) Method

WriteAsync() public method

public WriteAsync ( Byte buffer, Int32 offset, Int32 count, CancellationToken cancellationToken ) : Task
buffer Byte
offset System.Int32
count System.Int32
cancellationToken System.Threading.CancellationToken
return Task
        public override async Task WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
        {
            if (_isFinished)
                throw new WebSocketException("The write stream has been already flushed or disposed.");

            RemoveUTF8BOM(buffer, ref offset, ref count);

            while (count > 0)
            {
                BufferData(buffer, ref offset, ref count);

                if (_internalUsedBufferLength == _webSocket.Connection.SendBuffer.Count && count > 0)
                {
                    await _webSocket.Connection.WriteInternalAsync(_webSocket.Connection.SendBuffer, _internalUsedBufferLength, false, _isHeaderSent, _messageType, ExtensionFlags, cancellationToken).ConfigureAwait(false);
                    _internalUsedBufferLength = 0;
                    _isHeaderSent = true;                
                }
            }
        }
        public override async Task FlushAsync(CancellationToken cancellationToken)