On 1 May 2006, at 20:32, peter royal wrote:
On May 1, 2006, at 3:01 PM, Frederic Soulier wrote:
On 1 May 2006, at 19:43, peter royal wrote:
I think so :) .. This is more akin to what I've implemented in my
project. I'm using the ProtocolCodecFilter when a Decoder that
reads the message type and length, and once it is all there,
forwards the buffer to another decoder.
Ok so a primary decoder just keep saying NEED_DATA until a
complete message is ready.
When you write "forwards the buffer to another decoder" do you
mean a MINA decoder?
Aren't the decoder in the chain called automatically?
I'm not using the Demux stuff. My decoder extends
CumulativeProtocolDecoder, and the work is done in the doDecode
implementation.
My decoder works like this:
* For each message type, there is a decoder that can decode the
message. It knows nothing about there being a type/length code in
the ata
* There exists a "MyProtocolDecoder" (which is a
CumulativeProtocolDecoder) that has each of the above decoders
registered with it with a numeric code.
* When MyProtocolDecoder has a message's worth of data, it reads
the type code, looks up the decoder, uses ByteBuffer.limit() to set
the view to only the messgae, and passes that to the decoder that
was looked up.
And the decoders you have for each message are not necessarily MINA's
decoders, right?
If I follow you correctly:
- A CumulativeProtocolDecoder just keep requesting more data
until it has at least a full message in buffer (or more).
- This decoder class has a table indicating:
msg type 1 use my own decoder class AAA
msg type 2 use my own decoder class BBB
...
msg type x use my own decoder class ZZZ
- In the doDecode method (we know we have a full message of some
sort) we check the type of the message and we have a decoder for that
type (we hope so otherwise it's an invalid type of message) we call
the appropriate decoder to decode the message and return a message
object that ultimately will passed back to the IoHandler
messageReceived method.
If that's how it works I suspect I have to be careful with the
decoder table and decoders as as far as I understand each IoSession
has it's own instance of the filters so I don't really want to have a
Decoder in the filter chain that needs to instantiate all these
secondary decoders which should be the same for all clients
connecting really.
Is an IoSession per connection?
Thx.
--
Frederic P. Soulier
OpenPGP key available on http://pgpkeys.mit.edu/
1024D/BA6700ED 49A6 8E8E 4230 8D41 1ADE B649 3203 1DD2 BA67 00ED