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