If not implicitly covered in the case of "more than one complete message in a single buffer", we also need to deal with the case where "a sing buffer contains several complete messages AND an incomplete one".
Yong -----Original Message----- From: Emmanuel Lecharny [mailto:[email protected]] On Behalf Of Emmanuel Lecharny Sent: Monday, June 22, 2009 9:27 AM To: [email protected] Subject: Re: Handling variable length request/response in MINA David Rosenstrauch wrote: > I do something similar, using a binary protocol where messages vary in > length based on data-length values in the message. And yes, I use a > custom subclass of CumulativeProtocolDecoder for this. > > The code's a bit ugly, but it works. Essentially your decoder needs > to handle 3 possible cases: > > * full, syntactically correct message received > * part of a syntactically correct message received, and > * syntactically incorrect message received I would add a forth case : * more than one complete message in a single buffer. In this case, you have to loop until you have decoded all the messages, calling the next filter for each decoded message. This is what we do in Apache Directory to decode LDAP requests. -- -- cordialement, regards, Emmanuel Lécharny www.iktek.com directory.apache.org
