Thank you Michael for the answer! On 4/13/06, Michael Bauroth <[EMAIL PROTECTED]> wrote: > > I'll try to give you a first answer. Normally you will handle all the > received messages in your derived IoSession. So here could be one place > to check for different message types and react on them. > The other possibility is to use a derived DemuxingProtocolCodecFactory > and register different codecs here, which handle separately the incoming > data (parsing of ByteBuffer / decision for correct codec to use / > conversion into MessageObjects -> ProtocolDecoderOutput) ... see also > the SumUp example > The second case make it easy to handle the incoming messages as objects > instead of nontyped ByteBuffer queue over a simple switch case statement > in IoSession. > > Possibly you can handle (respond to sender) some of the simpler messages > directly in the codecs itself without handling them extra in IoSession? > > @community: Correct? ;)
Correct! I'd like to add more information though. The state information is stored in a map called session-specific attributes. You can get and set attributes by using IoSession.get/setAttribute(). Many filters use this attribute internally, and you can store your own state information there, too. If you don't like this data structure, you can use org.apache.mina.handler.multiton package to store the state information as an instance member. HTH, Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP key fingerprints: * E167 E6AF E73A CBCE EE41 4A29 544D DE48 FE95 4E7E * B693 628E 6047 4F8F CFA4 455E 1C62 A7DC 0255 ECA6
