Yes, it makes sense, but what about the other issue - multiple messages sent together? Can I decode a few messages and let MINA invoke my IoHandler's messageReceived method with all of them somehow?
On 4/1/06, peter royal <[EMAIL PROTECTED]> wrote: > > On Apr 1, 2006, at 2:39 PM, Zohar Amir wrote: > > 1. What's so bad about StreamIoHandler? > > its best used for integration with "legacy" code that is stream- > based. When working in MINA, you'll get the best performance by not > dropping back to blocking streams. > > > 2. I've searched in > > mina-0.9.2\examples\src\main\java\org\apache\mina\examples for > > ProtocolCodecFilter but didn't find anything - can you point at the > > right > > example? > > the 'sumup' example.. http://svn.apache.org/viewcvs.cgi/directory/ > trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/ > > > 3. Just from looking at the javadoc, it seems like messageReceived is > > invoked with a message - how is it created? Can this message be > > created with > > data from several packets arriving (cellular networks are sometimes > > slow)? > > What if several protocol messages are sent together? > > Thanks again, > > You provide the ProtocolCodecFilter with a ProtocolEncoder and a > ProtocolDecoder. Encoder is simple, it receives an application-level > message (some sort of Object) and should turn it into a ByteBuffer. > > For the Decoder, I highly recommend extending > CumulativeProtocolDecoder. It will help your packet problem. You > subclass 'doDecode', and if you don't have a full packet in the > ByteBuffer, just return false, and nothing further will happen. The > next received packet will be appended, and it will be called again, > Just decode a single message, return true, and if there is more data, > your decoder will be called again. > > Then, in your IoHandler / filters after the ProtocolCodecFilter, the > object in messageReceived will be the object that you decoded, rather > than a raw ByteBuffer. > > Make sense? > > -pete > > > > -- > [EMAIL PROTECTED] - http://fotap.org/~osi > > > > >
