Minor refact, moved Channel's attributesKey accessible by utils methods

This commit is contained in:
andsel
2016-01-24 19:21:24 +01:00
parent 43371d3068
commit 3be2667844
5 changed files with 80 additions and 44 deletions
@@ -87,14 +87,14 @@ public class NettyMQTTHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
String clientID = (String) NettyUtils.getAttribute(ctx, NettyUtils.ATTR_KEY_CLIENTID);
String clientID = NettyUtils.clientID(ctx.channel());
if (clientID != null && !clientID.isEmpty()) {
//if the channel was of a correctly connected client, inform messaging
//else it was of a not completed CONNECT message or sessionStolen
boolean stolen = false;
Boolean stolenAttr = (Boolean) NettyUtils.getAttribute(ctx, NettyUtils.ATTR_KEY_SESSION_STOLEN);
Boolean stolenAttr = NettyUtils.sessionStolen(ctx.channel());
if (stolenAttr != null && stolenAttr == Boolean.TRUE) {
stolen = stolenAttr;
stolen = true;
}
m_processor.processConnectionLost(clientID, stolen, ctx.channel());
}