Hi Alwyn,

On 5/20/07, Alwyn Schoeman <[EMAIL PROTECTED]> wrote:

I agree with mat-29.

In order for DemuxingProtocolCodecFactory to call a specific Decoder or
Encoder, it will need to know what the type of the message is.

Each MessageDecoder can determine if the incoming data is for itself
or not.  DemuxingProtocolCodecFactory calls MessageDecoder.decodable()
to find an appripriate MessageDecoder.

Question is, how does it know?

It calls decodable() of all registered MessageDecoders.

Does it assume a specific value at a specific offset in the data stream?

No.  Your MessageDecoder.decodable() decides.

Does it call all the Decoders in sequence until a Decoder acknowledges that
it is meant for it?  (Hope not)

Yes, but it doesn't perform that bad.

Assume you have to handle different messages from different established
protocols (cannot redesign), how would you handle that?

If those protocols are all implemented with
DemuxingProtocolCodecFactory, you can register all MessageDecoder
implementations and that's all.  If you want to disable all
MessageDecoders from one protocol once a message from the other
protocol is received, you can take care of it in your IoHandler
implementation.

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to