private async Task HandleResponseMessageAsync(TResponse msg)
        {
            var header = _protocol.MessageFactory.CreateInvocationMessageReceived();

            if (!_sender.TryWrite(header))
            {
                await _sender.WriteOrDisposeAsync(header, CancellationToken).ConfigureAwait(false);
            }
            Log.Debug("Sent confirmation about received response of type {0}", msg.GetType().Name);
            if (!_responses.TryWrite(msg))
            {
                await _responses.WriteAsync(msg, CancellationToken).ConfigureAwait(false);
            }
            Log.Debug("Consumed response of type {0}", msg.GetType().Name);
        }
        private async Task HandleIncomingMessageFrameAsync(TransportMessageFrame frame)
        {
            _log.Trace("Consuming message frame: {0}", frame);
            _curIncomingMessage.Write(frame.Payload.Array, frame.Payload.Offset, frame.Payload.Count);
            if (!frame.HasMore)
            {
                _curIncomingMessage.Position = 0;
                var msg = _marshaller.Decode(_curIncomingMessage);
                await _buffer.Out.WriteAsync(msg, CancellationToken).ConfigureAwait(false);

                _log.Debug("Received message of type {0} with length {1}", msg.GetType().Name, _curIncomingMessage.Length);
                _curIncomingMessage.Position = 0;
                _curIncomingMessage.SetLength(0);
                _incomingStreamState = IncomingStreamState.Open;
                var header = _protocol.MessageFactory.CreateInvocationMessageReceived();
                await _sender.WriteOrDisposeAsync(header, CancellationToken).ConfigureAwait(false);
            }
        }