public static AMQPHeader getAMQP(IByteBuffer buf)
        {
            TLVAmqp list = TLVFactory.getTlv(buf);

            if (list.Code != AMQPType.LIST_0 && list.Code != AMQPType.LIST_8 && list.Code != AMQPType.LIST_32)
            {
                throw new MalformedMessageException("Received amqp-header with malformed arguments");
            }

            AMQPHeader header = null;

            Byte        byteCode = list.Constructor.getDescriptorCode().Value;
            HeaderCodes code     = (HeaderCodes)byteCode;

            switch (code)
            {
            case HeaderCodes.ATTACH:
                header = new AMQPAttach();
                break;

            case HeaderCodes.BEGIN:
                header = new AMQPBegin();
                break;

            case HeaderCodes.CLOSE:
                header = new AMQPClose();
                break;

            case HeaderCodes.DETACH:
                header = new AMQPDetach();
                break;

            case HeaderCodes.DISPOSITION:
                header = new AMQPDisposition();
                break;

            case HeaderCodes.END:
                header = new AMQPEnd();
                break;

            case HeaderCodes.FLOW:
                header = new AMQPFlow();
                break;

            case HeaderCodes.OPEN:
                header = new AMQPOpen();
                break;

            case HeaderCodes.TRANSFER:
                header = new AMQPTransfer();
                break;

            default:
                throw new MalformedMessageException("Received amqp-header with unrecognized performative");
            }

            header.fillArguments((TLVList)list);

            return(header);
        }
        public Boolean Disconnect()
        {
            if (_client.IsConnected())
            {
                if (_timers != null)
                {
                    _timers.StopAllTimers();
                }

                AMQPEnd end = new AMQPEnd();
                end.Channel = _channel;
                _timers.Store(-1, end);
                _client.Send(end);
            }

            return(false);
        }