Apache MINA uses the concept of Protocol Decoder to decoder read bytes into High Level Message objects. There are conditions in which a single packet may not contain the complete bytes to convert raw message into High Level Objects. For such situations, CumulativeProtocolDecoder can be used. Basically, encoder makes the framework buffer the data, till the complete data is received, to convert the byte into a high level object.
So, how do we use this Decoder
Extend from the class CumulativeProtocolDecoder and implement the doDecode().
Conditions to take care of
- read the IoBuffer and decode as per yur logic
- If the data is sufficient to create your message, return true, else return false