Пример #1
0
        protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket)
        {
            var response   = new BinaryResponse();
            var serverData = new Dictionary <string, string>();
            var retval     = false;

            while ((await response.ReadAsync(socket)) && response.KeyLength > 0)
            {
                retval = true;

                var data  = response.Data;
                var key   = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength);
                var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength);

                serverData[key] = value;
            }

            this.result     = serverData;
            this.StatusCode = response.StatusCode;

            var result = new BinaryOperationResult()
            {
                StatusCode = StatusCode
            };

            result.PassOrFail(retval, "Failed to read response");
            return(result);
        }
Пример #2
0
        protected internal override async Task <IOperationResult> ReadResponseAsync(PooledSocket socket, CancellationToken cancellationToken = default(CancellationToken))
        {
            var response   = new BinaryResponse();
            var serverData = new Dictionary <string, string>();
            var success    = false;

            while (await response.ReadAsync(socket, cancellationToken).ConfigureAwait(false) && response.KeyLength > 0)
            {
                success = true;

                var data  = response.Data;
                var key   = BinaryConverter.DecodeKey(data.Array, data.Offset, response.KeyLength);
                var value = BinaryConverter.DecodeKey(data.Array, data.Offset + response.KeyLength, data.Count - response.KeyLength);

                serverData[key] = value;
            }

            this._result    = serverData;
            this.StatusCode = response.StatusCode;

            var result = new BinaryOperationResult()
            {
                StatusCode = StatusCode
            };

            result.PassOrFail(success, "Failed to read response");
            return(result);
        }
Пример #3
0
        protected override IOperationResult ProcessResponse(BinaryResponse response)
        {
            var r      = response.StatusCode == 0;
            var result = new BinaryOperationResult();

            if (this.locator != null &&
                !VBucketAwareOperationFactory.GuessResponseState(response, out this.state))
            {
                return(result.Fail("Process response failed"));
            }

            return(result.PassOrFail(r, "Processing response failed"));
        }
Пример #4
0
        protected internal override IOperationResult ReadResponse(PooledSocket socket)
        {
            var response = new BinaryResponse();
            var retval   = response.Read(socket);

            this.StatusCode = StatusCode;
            var result = new BinaryOperationResult()
            {
                Success    = retval,
                StatusCode = this.StatusCode
            };

            result.PassOrFail(retval, "Failed to read response");
            return(result);
        }
        protected internal override async Task <IOperationResult> ReadResponseAsync(PooledSocket socket, CancellationToken cancellationToken = default(CancellationToken))
        {
            var response = new BinaryResponse();
            var success  = await response.ReadAsync(socket, cancellationToken).ConfigureAwait(false);

            this.StatusCode = StatusCode;
            var result = new BinaryOperationResult()
            {
                Success    = success,
                StatusCode = this.StatusCode
            };

            result.PassOrFail(success, "Failed to read response");
            return(result);
        }
Пример #6
0
        protected internal override IOperationResult ReadResponse(PooledSocket socket)
        {
            var response = new BinaryResponse();
            var success  = response.Read(socket);

            this.StatusCode = response.StatusCode;
            this.Data       = response.Data.Array;

            var result = new BinaryOperationResult
            {
                StatusCode = this.StatusCode
            };

            result.PassOrFail(success, "Failed to read response");
            return(result);
        }
Пример #7
0
        protected internal override async ValueTask <IOperationResult> ReadResponseAsync(PooledSocket socket)
        {
            var response = new BinaryResponse();

            var retval = await response.ReadAsync(socket);

            this.StatusCode = response.StatusCode;
            this.Data       = response.Data.Array;

            var result = new BinaryOperationResult
            {
                StatusCode = this.StatusCode
            };

            result.PassOrFail(retval, "Failed to read response");
            return(result);
        }