sorry.
I received large packet, prints "RAW DATA" twice.
first, print RAW DATA include packet header.
second, print RAW DATA (just data).
sorry, English is poor.
<all code>
public class PacketReqAnalysis extends CumulativeProtocolDecoder
{
protected boolean doDecode(IoSession session, ByteBuffer in,
ProtocolDecoderOutput out) throws Exception {
logger.debug( "RAW DATA - " + in.getHexDump() );
int start = in.get() & 0xFF;
if( start == PacketDefine.START ) {
ByteBuffer pk = ByteBuffer.allocate( 2, false );
pk.setAutoExpand( true );
pk.put( (byte)start );
pk.putShort( (short)(in.getShort() & 0xFFFF) );
pk.put( (byte)in.get() );
pk.put( (byte)in.get() );
int size = in.getInt();
pk.putInt( size );
pk.put( (byte)in.get() );
pk.put( (byte)in.get() );
byte[] bytes = new byte[ size ];
in.get( bytes );
pk.put( bytes );
MessageReq request = new MessageReq( session, pk, out,
start );
out.write( acu_request );
return true;
} else {
logger.debug( "out doDecode-------------------" );
logger.debug( "buf is " + in.getHexDump() );
logger.debug( "out doDecode-------------------" );
return false;
}
}
}
On 10/15/07, Niklas Therning <[EMAIL PROTECTED]> wrote:
> Sungwon Jung wrote:
> > Hello. I'm using MINA 1.1.2.
> >
> > I'm using CumulativeProtocolDecoder.
> > When I recieved large size packet(about 220bytes), the packet is splited.
> > How can I assemble the splited packet?
> >
> > Thank you.
> >
> >
> > my code>
> > public class PacketReqAnalysis extends CumulativeProtocolDecoder
> > {
> >
> > protected boolean doDecode(IoSession session, ByteBuffer in,
> > ProtocolDecoderOutput out) throws Exception {
> >
> > if( start == PacketDefine.START ) {
> > return true;
> > } else {
> > return false;
> > }
> > }
> > }
> >
> Your code looks weird. Is this really all code? Where does the start
> variable come from?
>
> /Niklas