Channel attachments?
Jesse Hutton
jesse.hutton at gmail.com
Fri Jun 11 12:01:31 EDT 2010
On Fri, Jun 11, 2010 at 11:30 AM, Robert Wahlstedt <rob at isketch.net> wrote:
>
> On Jun 10, 2010, at 22:46 , blakeman8192 wrote:
>
> > I need a more elegant way to keep track of different objects (i.e. a
> Player object) for a Channel.
> > Is this overlooked in the Netty design, or (more likely) am I missing
> something?
>
> This is probably a very common functionality needed when building Netty
> based programs. More attention in the javadocs/documentation for best
> practices would be nice.
>
> I have solved it simply by subclassing DefaultChannelPipeline and putting
> the variables I need there. That way all of my handlers can access it by
> ChannelHandlerContext.getPipeline()
>
>
> /Rob
Just to add one more variation on the theme, my approach was to add whatever
state variables I needed to the final upstream handler in my pipeline
factory. Then, to get access I can do channel.getPipeline().getLast(),
casting it to the appropriate class.
Jesse
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100611/f233e07e/attachment.html
More information about the netty-users
mailing list