On 5/16/07, mat <[EMAIL PROTECTED]> wrote:
2007/4/25, Trustin Lee <[EMAIL PROTECTED]>:
>
> I'd like to add more pepper to Peter's comment. :)
>
> On 4/25/07, peter royal <[EMAIL PROTECTED]> wrote:
> > On Apr 21, 2007, at 8:38 AM, mat wrote:
> > > I implemented my protocol encoding in the procotol filter and I
> > > used one
> > > session one object method. I just wonder if I try to boardbast the
> > > message
> > > to N clients, which means the encoding part will be called N times?
>
> Yes.
>
> > > If so,
> > > should I move my encoding part in the IoHandler which means
> > > encoding once
> > > and send bytes to sessions(without encoding N times but once).
>
> You can do that, but it's not encouraged. I'd use a LRU cache so the
> encoded buffer is cached, and reused on and on. Of course, you will
> have to use the duplicate of the encoded buffer:
I wonder why it's NOT encouraged? What's difference between your methods and
mine?
Your approach mixes codec and communication flow, which can cause
potentially spaghetti protocol implementation. Separating each part
as much as possible will increase maintainability IMHO.
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6