Hi !!!

I have a little problem.
I have written my own MessageEncoder for encoding my messages

For that in Encoder in encode function i use

public void encode(IoSession session, Object message, ProtocolEncoderOutput
out)
  throws Exception
{
 Message msg = (Message) message;
 ByteBuffer buf = ByteBuffer.allocate(20);
 buf.setAutoExpand(true);


 //Add data to ByteBuffer
 buf.putString(msg.getFromID(), charsetEncoder); // FromID is String and
Encoder is UTF-8
 buf.putString(msg.getToID(), charsetEncoder ); // ToID is String and
Encoder is UTF-8
 buf.putString(msg.getTimeStamp(), charsetEncoder ); // TimeStamp is String
and Encoder is UTF-8
 buf.putInt(msg.getLength());
 buf.put(msg.getData());

 buf.flip();
 out.write(buf);

}



Whenever i use my decoder to decode the same message it gives me all the
strings in the first call itself.

That is when i call

buf.getString(charsetDecoder); it gives me all FromID + ToID + TimeStamp and
other calls to getString returns empty strings.

What should i do and how to rectify this problem.

Thanks and Regards,

Robin

Reply via email to