CqlSharp.Protocol.FrameReader.ReadShortBytesAsync C# (CSharp) Method

ReadShortBytesAsync() public method

Reads the short bytes async.
public ReadShortBytesAsync ( ) : Task
return Task
        public async Task<byte[]> ReadShortBytesAsync()
        {
            ushort len = await ReadShortAsync().AutoConfigureAwait();

            if(len == 0)
                return new byte[0];

            //read the data segment
            if(!TryGetSegmentFromBuffer(len))
                await ReadSegmentAsync(len).AutoConfigureAwait();

            //copy data from buffer into new array if necessary
            byte[] data = _lastReadSegment.Array == _buffer ? CopySegmentToArray() : _lastReadSegment.Array;

            return data;
        }

Usage Example

示例#1
0
        protected override async Task InitializeAsync()
        {
            FrameReader reader = Reader;

            ResultOpcode = (ResultOpcode)await reader.ReadIntAsync().ConfigureAwait(false);

            switch (ResultOpcode)
            {
            case ResultOpcode.Void:
                break;

            case ResultOpcode.Rows:
                Schema = await ReadCqlSchemaAsync().ConfigureAwait(false);

                _count = await reader.ReadIntAsync().ConfigureAwait(false);

                break;

            case ResultOpcode.SetKeyspace:
                Keyspace = await reader.ReadStringAsync().ConfigureAwait(false);

                break;

            case ResultOpcode.SchemaChange:
                Change = await reader.ReadStringAsync().ConfigureAwait(false);

                Keyspace = await reader.ReadStringAsync().ConfigureAwait(false);

                Table = await reader.ReadStringAsync().ConfigureAwait(false);

                break;

            case ResultOpcode.Prepared:
                PreparedQueryId = await reader.ReadShortBytesAsync().ConfigureAwait(false);

                Schema = await ReadCqlSchemaAsync().ConfigureAwait(false);

                break;

            default:
                throw new ArgumentException("Unexpected ResultOpcode");
            }

            //_readLock = new SemaphoreSlim(1);
        }
All Usage Examples Of CqlSharp.Protocol.FrameReader::ReadShortBytesAsync