I am using an instance of DemuxingProtocolDecoder class with my application. Under the package org.apache.mina.filter.codec.demux
there are some interfaces and classes that you can use to decode your messages. There is an interface called MessageDecoder
. Create your own class that implements this interface and MINA will the work. Something like this,
public class MyDecoder implements MessageDecoder {
public MessageDecoderResult decode(IoSession session, IoBuffer buffer, ProtocolDecoderOutput decoderOutput) throws Exception {
/* Your
decode
mechanism */
decoderOutput.write(message); // don't forget to write your decoded message object at some point.
return MessageDecoder.OK; //or something else that matches your needs.
}
}