ReadShortBytesAsync() public method

Reads the short bytes async.
public ReadShortBytesAsync ( ) : Task
return Task
コード例 #1
0
ファイル: ResultFrame.cs プロジェクト: priyaparul/CqlSharp
        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);
        }
コード例 #2
0
        protected override async Task InitializeAsync()
        {
            FrameReader stream = Reader;
            var         code   = (ErrorCode)await stream.ReadIntAsync().ConfigureAwait(false);

            string msg = await stream.ReadStringAsync().ConfigureAwait(false);

            switch (code)
            {
            case ErrorCode.Unavailable:
            {
                var cl = (CqlConsistency)await stream.ReadShortAsync().ConfigureAwait(false);

                int required = await stream.ReadIntAsync().ConfigureAwait(false);

                int alive = await stream.ReadIntAsync().ConfigureAwait(false);

                Exception = new UnavailableException(msg, cl, required, alive);
                break;
            }

            case ErrorCode.WriteTimeout:
            {
                var cl = (CqlConsistency)await stream.ReadShortAsync().ConfigureAwait(false);

                int received = await stream.ReadIntAsync().ConfigureAwait(false);

                int blockFor = await stream.ReadIntAsync().ConfigureAwait(false);

                string writeType = await stream.ReadStringAsync().ConfigureAwait(false);

                Exception = new WriteTimeOutException(msg, cl, received, blockFor, writeType);
                break;
            }

            case ErrorCode.ReadTimeout:
            {
                var cl = (CqlConsistency)await stream.ReadShortAsync().ConfigureAwait(false);

                int received = await stream.ReadIntAsync().ConfigureAwait(false);

                int blockFor = await stream.ReadIntAsync().ConfigureAwait(false);

                bool dataPresent = 0 != await stream.ReadByteAsync().ConfigureAwait(false);

                Exception = new ReadTimeOutException(msg, cl, received, blockFor, dataPresent);
                break;
            }

            case ErrorCode.Syntax:
                Exception = new SyntaxException(msg);
                break;

            case ErrorCode.Unauthorized:
                Exception = new UnauthorizedException(msg);
                break;

            case ErrorCode.Invalid:
                Exception = new InvalidException(msg);
                break;

            case ErrorCode.AlreadyExists:
                string keyspace = await stream.ReadStringAsync().ConfigureAwait(false);

                string table = await stream.ReadStringAsync().ConfigureAwait(false);

                Exception = new AlreadyExistsException(msg, keyspace, table);
                break;

            case ErrorCode.Unprepared:
                byte[] unknownId = await stream.ReadShortBytesAsync().ConfigureAwait(false);

                Exception = new UnpreparedException(msg, unknownId);
                break;

            default:
                Exception = new ProtocolException(code, msg);
                break;
            }
        }