[email protected] wrote:
If I understand MINA right I need to implement my own protocol encoder and decoder to support my protocol. The encoder looks quite simple but the decoder looks a bit strange. If I understand it right the decoder should be aware that a message might be split to multiple doDecode() calls. The examples I found save some state in the session. I'm ok so far. But I do nut understand the buffer handling. If I'm right, I'm allowed to read from position() to limit(). But what happens if I read to limit() and have no message complete? Do I get the same buffer next time again and can store the position where I stopped? If I set a mark() is it stored over multiple doDecode() calls? How much buffer is available? How do I mark the read part of the buffer as read? Is there an example that explains how to handle the multiple doDecode() messages and the buffer handling?
Tt's really having the same behavior than the standard ByteBuffer.

If you have to read more than one buffer to decode your message (ie your decoder will be called more than once), then either you store the read bytes up to the limit (if there are not enough bytes to decode your message) and store them in the session, or you have to concatenate the buffer into another one waiting to have read all the needed bytes. Then call the decoder.

A third case is when you have more than one message in your buffer : you will have call the decoder it more than once.

In any case, just have a look at :
http://mina.apache.org/tutorial-on-protocolcodecfilter-for-mina-2x.html

and
http://mina.apache.org/handling-packet-fragementation.html







--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to