Hi caantini,

First please read:
http://www.nabble.com/How-can-I-configure-multiple-decoders-in-MINA--tf3561571.html#a9946908

Actually I spent some time on this issue. Let me explain to you.
1) decodable does all the magics here. Mina calls the decodable of all the
registered MessageDecoder classes until one of
MessageDecoderResult.OKreturns. I believe in buffer will be rewind to
the beginning.
2) Pass the opCodeBytebyte into decoder, and decide if in.get() ==
opCodeBytebyte  in decodable, if SO, return MessageDecoderResult.OK.
Therefore you do NOT need switch in your decodable.
3) Is it a overhead since Mina calls the decodable? Trustin said NO.

On 11/9/07, csantini <[EMAIL PROTECTED]> wrote:
>
>
> I have many Message classes that implements MessageDecoder and
> MessageEncoder, and they are all listed in a DemuxingProtocolCodecFactory.
> Now I need to be able to choose what decoder/encoder to use just depending
> on the second byte (opcode) I receive; I could implement a decodable() for
> each Message returning OK if the byte is right but it's slow with many
> Messages! I need to do something like this:
>
> switch(opCodeByte){
> case 0x01: use HelloMessageDecoder
> case 0x02: use DataMessageDecoder
> ...
> }
>
> Maybe DemuxingIoHandler is the right way but there is no doc about, could
> you help me ?
> Thanks for your work and your beautiful framework!
>
> --
> View this message in context:
> http://www.nabble.com/Many-message-decoder-encoder-tf4776815s16868.html#a13664414
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>

Reply via email to