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 void Unsubscribe(String[] topics)
 {
     foreach (String topic in topics)
     {
         if (_usedIncomingMappings.ContainsKey(topic))
         {
             AMQPDetach detach = new AMQPDetach();
             detach.Channel = _channel;
             detach.Closed  = true;
             detach.Handle  = _usedIncomingMappings[topic];
             _client.Send(detach);
         }
         else
         {
             _dbInterface.DeleteTopic(topic);
             if (_listener != null)
             {
                 _listener.MessageReceived(MessageType.UNSUBACK);
             }
         }
     }
 }