Java Code Examples for io.netty.channel.ChannelHandlerContext.attr()

The following are Jave code examples for showing how to use attr() of the io.netty.channel.ChannelHandlerContext class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: wecard-server   File: NettyServerHandler.java   View Source Code Vote up 5 votes
/**
 * 连接被关闭
 * @param ctx
 * @throws Exception
 */
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {

    AttributeKey<Session> attrKeySession = AttributeKey.valueOf("Session");
    Attribute<Session> attrSession = ctx.attr(attrKeySession);
    Session session = attrSession.get();

    logger.warn("client diconnect!");
    super.channelInactive(ctx);
}