public override async void ChannelRead(IChannelHandlerContext context,
                                               object message)
        {
            switch (message)
            {
            case EslMessage msg when !string.IsNullOrEmpty(msg?.ContentType()):
                switch (msg.ContentType())
                {
                case EslHeadersValues.AuthRequest:
                    await _outboundListener.OnAuthentication();

                    break;

                case EslHeadersValues.CommandReply:
                    var commandAsyncEvent1 = CommandAsyncEvents.Dequeue();
                    var cmdResponse        = new CommandReply(commandAsyncEvent1.Command.Command,
                                                              msg);
                    commandAsyncEvent1.Complete(cmdResponse);
                    break;

                case EslHeadersValues.ApiResponse:
                    var commandAsyncEvent = CommandAsyncEvents.Dequeue();
                    var apiResponse       = new ApiResponse(commandAsyncEvent.Command.Command,
                                                            msg);
                    commandAsyncEvent.Complete(apiResponse);
                    break;

                case EslHeadersValues.TextEventPlain:
                    _outboundListener.OnEventReceived(msg);
                    break;

                case EslHeadersValues.TextDisconnectNotice:
                    var channel = context.Channel;
                    var address = channel.RemoteAddress;

                    await _outboundListener.OnDisconnectNotice(msg,
                                                               address);

                    break;

                case EslHeadersValues.TextRudeRejection:
                    await _outboundListener.OnRudeRejection();

                    break;

                default:
                    // Unexpected freeSwitch message
                    _logger.Warn("Unexpected message content type [{0}]",
                                 msg.ContentType());
                    break;
                }
                break;

            default:
                // Unexpected freeSwitch message
                _logger.Warn("Unexpected message [{0}]",
                             message);
                return;
            }
        }
        public override async void ChannelRead(IChannelHandlerContext context,
                                               object message)
        {
            var eslMessage  = message as EslMessage;
            var contentType = eslMessage?.ContentType();

            if (string.IsNullOrEmpty(contentType))
            {
                return;
            }
            // Handle command/reply
            if (contentType.Equals(EslHeadersValues.CommandReply))
            {
                var commandAsyncEvent = CommandAsyncEvents.Dequeue();
                var reply             = new CommandReply(commandAsyncEvent.Command.Command, eslMessage);
                commandAsyncEvent.Complete(reply);
                return;
            }

            // Handle api/response
            if (contentType.Equals(EslHeadersValues.ApiResponse))
            {
                var commandAsyncEvent = CommandAsyncEvents.Dequeue();
                var apiResponse       = new ApiResponse(commandAsyncEvent.Command.Command,
                                                        eslMessage);
                commandAsyncEvent.Complete(apiResponse);
                return;
            }

            // Handle text/event-plain
            if (contentType.Equals(EslHeadersValues.TextEventPlain))
            {
                await _inboundListener.OnEventReceived(eslMessage);

                return;
            }

            // Handle disconnect/notice message
            if (contentType.Equals(EslHeadersValues.TextDisconnectNotice))
            {
                var channel = context.Channel;
                var address = channel.RemoteAddress;
                await _inboundListener.OnDisconnectNotice(eslMessage, address);

                return;
            }

            // Handle rude/rejection message
            if (contentType.Equals(EslHeadersValues.TextRudeRejection))
            {
                await _inboundListener.OnRudeRejection();

                return;
            }

            // Unexpected freeSwitch message
            _logger.Warn("Unexpected message content type [{0}]", contentType);
        }