In other words: try replacing in.get(0) with in.get()
Maarten
On 9/13/07, Trustin Lee <[EMAIL PROTECTED]> wrote:
>
> On 9/12/07, Sungwon Jung <[EMAIL PROTECTED]> wrote:
> > thank you reply.
> >
> > doDecode() implementation is below.
> >
> > --
> > public class ACUPacketReqAnalysis extends CumulativeProtocolDecoder
> > {
> > Logger logger = Logger.getLogger( this.getClass() );
> >
> > private int device = Constants.DEVICE_NONE;
> >
> > protected boolean doDecode(IoSession session, ByteBuffer in,
> > ProtocolDecoderOutput out) throws Exception {
> > int start = in.get( 0 ) & 0xFF;
> >
> > if( start == PacketDefineACU.START ) {
> > session.setAttribute( Constants.SESSION_DEVICE,
> Constants.DEVICE_ACU );
> >
> > ACUMessageReq acu_request = new ACUMessageReq(
> session, in, out, start );
> > out.write( acu_request );
> >
> > return true;
> > } else {
> > return false;
> > }
> > }
> > }
>
> It seems like you don't move the position of the input buffer after
> decoding a message. Please more the buffer position to the end of the
> message (note that it's not the end of the buffer).
>
> And you shall not use absolute addressing (e.g. in.get(0)) because you
> cannot assume that the offset (position) of the first byte is always
> zero.
>
> HTH,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>