Client disconnect

Christian Migowski chrismfwrd at gmail.com
Thu May 7 08:01:48 EDT 2009


Hi Matthias,

first off a disclaimer: i am only a Netty USER as well so what I write
may not be correct but only what I think is correct since the truth
(source code is always the truth!) is not mine ;)

On Thu, May 7, 2009 at 10:43 AM, matthias.s.
<matthias.scudlik at pangora.com> wrote:
>
> You helped me to understand how netty works, the only thing i'm not sure
> about
> is how to get a ChannelHandlerContext outside the predefined methods - do i
> have to set a field on connection? but it should not be the same context
> everytime.

It depends on wether you're a server or a client. When you are a
server, you will always get called and as Frederic suggested it is
better to get the channel from the ChannelHandlerContext  from the
parameter of the "predefined methods" (just pass it on if you're
calling your own classes/methods from within there). If your server
needs to actively send out things to the client, get the channel in
channelConnected(...) or channelOpen(...) from the
ChannelHandlerContext (CHC) in this methods and store it somewhere
where you can use it.

When you are a client, you don't get the channel from the CHC, maybe
this was confusing in what Frederic wrote, but from the ChannelFuture
that you get from a connect(...) method.

hth,
best regards,
christian!

> I figured out that understanding netty is not that simple but at least it
> works for now.

I do think so too, but IMO the design and principles are rather good
which is more important then being easy understandable, and then
Trustin is busy as a bee and has (IMO) an open ear to his community,
so things can actually improve :)

hth,
best regards,
christian!



More information about the netty-users mailing list