}
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())
{
incomplete[channel] = command;
}
else
{
emit(channel, command);
}
break;
case HEADER:
command = incomplete[channel];
List<Struct> structs = new ArrayList(2);
while (dec.hasRemaining())
{
structs.add(dec.readStruct32());
}
command.setHeader(new Header(structs));
if (frame.isLastSegment())
{
incomplete[channel] = null;