per session attributes

"Trustin Lee (이희승)" trustin at gmail.com
Mon Dec 28 07:02:29 EST 2009


Hi falconair,

myAttr (i.e. a ChannelLocal instance) is supposed to be accessible from
any handlers, so I would expose it as a public static final member
variable of some class.  For example:

    public class MyChannelAttrs {
        public static final ChannelLocal<String> myAttr = ...;
    }

HTH,
Trustin

falconair wrote:
> I am trying to figure out how to set variables per connection.  Once a client
> connects to my server, they send a log on message with some attributes.  I'd
> like to make those attributes available to every filter/handler in my
> pipeline.
> 
> Previous messages in the mailing list point to ChannelLocal, such as the
> following example:
> 
> final ChannelLocal<String> myAttr = new ChannelLocal<String>(); 
>   ... 
>   String a = myAttr.get(channel); 
>   myAttr.set(channel, "newValue"); 
>   myAttr.remove(channel); 
> 
> But I'm not sure how to use it exactly.  Am I supposed to 'put' myAttr in
> the ChannelHandlerContext?  In other words, say my logon handler retrieves
> my attribute, how do I make it available to subsequent handlers?
> 
> Thanks

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20091228/0d5379a2/attachment.bin 


More information about the netty-users mailing list