コード例 #1
0
        public async Task <ResponseMessage> ReceiveMessageAsync(
            int responseTo,
            IMessageEncoderSelector encoderSelector,
            MessageEncoderSettings messageEncoderSettings,
            CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(encoderSelector, nameof(encoderSelector));
            ThrowIfDisposedOrNotOpen();

            var helper = new ReceiveMessageHelper(this, responseTo, messageEncoderSettings, _compressorSource);

            try
            {
                helper.ReceivingMessage();
                using (var buffer = await ReceiveBufferAsync(responseTo, cancellationToken).ConfigureAwait(false))
                {
                    var message = helper.DecodeMessage(buffer, encoderSelector, cancellationToken);
                    helper.ReceivedMessage(buffer, message);
                    return(message);
                }
            }
            catch (Exception ex)
            {
                helper.FailedReceivingMessage(ex);
                throw;
            }
        }
コード例 #2
0
        public ResponseMessage ReceiveMessage(
            int responseTo,
            IMessageEncoderSelector encoderSelector,
            MessageEncoderSettings messageEncoderSettings,
            CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(encoderSelector, nameof(encoderSelector));
            ThrowIfDisposedOrNotOpen();

            var helper = new ReceiveMessageHelper(this, responseTo, messageEncoderSettings);

            try
            {
                helper.ReceivingMessage();
                using (var buffer = ReceiveBuffer(responseTo, cancellationToken))
                {
                    var message = helper.DecodeMessage(buffer, encoderSelector, cancellationToken);
                    helper.ReceivedMessage(buffer, message);
                    return(message);
                }
            }
            catch (Exception ex)
            {
                helper.FailedReceivingMessage(ex);
                throw;
            }
        }
コード例 #3
0
        public async Task<ResponseMessage> ReceiveMessageAsync(
            int responseTo,
            IMessageEncoderSelector encoderSelector,
            MessageEncoderSettings messageEncoderSettings,
            CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(encoderSelector, nameof(encoderSelector));
            ThrowIfDisposedOrNotOpen();

            var helper = new ReceiveMessageHelper(this, responseTo, messageEncoderSettings);
            try
            {
                helper.ReceivingMessage();
                using (var buffer = await ReceiveBufferAsync(responseTo, cancellationToken).ConfigureAwait(false))
                {
                    var message = helper.DecodeMessage(buffer, encoderSelector, cancellationToken);
                    helper.ReceivedMessage(buffer, message);
                    return message;
                }
            }
            catch (Exception ex)
            {
                helper.FailedReceivingMessage(ex);
                throw;
            }
        }