private void assemble()

in client/src/main/java/org/apache/qpid/transport/network/Assembler.java [175:253]


    private void assemble(Frame frame, ByteBuffer segment)
    {
        BBDecoder dec = _decoder.get();
        dec.init(segment);

        int channel = frame.getChannel();
        Method command;

        switch (frame.getType())
        {
        case CONTROL:
            int controlType = dec.readUint16();
            Method control = Method.create(controlType);
            control.read(dec);
            emit(channel, control);
            break;
        case COMMAND:
            int commandType = dec.readUint16();
            // read in the session header, right now we don't use it
            int hdr = dec.readUint16();
            command = Method.create(commandType);
            command.setSync((0x0001 & hdr) != 0);
            command.read(dec);
            if (command.hasPayload() && !frame.isLastSegment())
            {
                setIncompleteCommand(channel, command);
            }
            else
            {
                emit(channel, command);
            }
            break;
        case HEADER:
            command = getIncompleteCommand(channel);
            List<Struct> structs = null;
            DeliveryProperties deliveryProps = null;
            MessageProperties messageProps = null;

            while (dec.hasRemaining())
            {
                Struct struct = dec.readStruct32();
                if(struct instanceof  DeliveryProperties && deliveryProps == null)
                {
                    deliveryProps = (DeliveryProperties) struct;
                }
                else if(struct instanceof MessageProperties && messageProps == null)
                {
                    messageProps = (MessageProperties) struct;
                }
                else
                {
                    if(structs == null)
                    {
                        structs = new ArrayList<Struct>(2);
                    }
                    structs.add(struct);
                }

            }
            command.setHeader(new Header(deliveryProps,messageProps,structs));

            if (frame.isLastSegment())
            {
                setIncompleteCommand(channel, null);
                emit(channel, command);
            }
            break;
        case BODY:
            command = getIncompleteCommand(channel);
            command.setBody(segment);
            setIncompleteCommand(channel, null);
            emit(channel, command);
            break;
        default:
            throw new IllegalStateException("unknown frame type: " + frame.getType());
        }

        dec.releaseBuffer();
    }