Hi,
I've been evaluating Mina 2.x as a possible Io Framework for implementing a TCP
client I'm working on. The protocol I'll be using has various packet types
defined, and I'll only be interested in a few of them, but I could potentially
receive any packet type that is defined. My initial thought was to use the
DemuxingProtocol approach similar to what is shown in the SumUp example. It
looked like I'd be able to evaluate each packet type received using the
MessageDecoder.decodable(...) method, returning OK for the packet types I'll be
implementing and NOT_OK for all others, but after re-reading the Tutorial on
ProtocolCodecFilter for Mina 2.x and varioius emails, etc, I started
questioning if this approach will actually work.
My concern is I will potentially be discarding messages I'm interested in when
I return NOT_OK from the decodable(...) method when the message buffer being
evaluated contains 2 or more messages; the first message in the buffer is not
one any decoder can handle, but the second (or 3rd) message in the buffer is
one that is handled.
It seems there would be a similar issue if I attempted to continue to evaluate
the buffer after encountering a message the current decoder does not handle,
but then later returning OK when finding a message the current decoder does
handle; the buffer contains 2 messages, the first of which is not handled by
the current decoder, but the second one is; however, the first message which
will now be discarded could have been handled by one of my other decoders.
So, given my limited understanding of the Mina Framework at this point, my
question is, is this a valid concern, or is there something I'm missing or
should be doing to avoid this issue?
Thanks for your time and feedback,
Daryl