Added check to avoid creation of LostConnectionEvents for not yet completed connects (fix issue #88)

This commit is contained in:
andsel
2015-09-22 15:29:23 +02:00
parent 56f122b8b9
commit f7466fd968
5 changed files with 65 additions and 3 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
#the password is sha256(passwd)
testuser:36767030e79073783c8e9b299d9f8f1d4cd66baa82cd8869caad8dbb55204099
testuser:0d6be69b264717f2dd33652e212b173104b4a647b7c11ae72e9885f11cd312fb
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import io.netty.handler.codec.CorruptedFrameException;
import org.apache.commons.codec.binary.StringUtils;
import org.eclipse.moquette.spi.IMessaging;
import org.eclipse.moquette.proto.Utils;
import org.eclipse.moquette.proto.messages.AbstractMessage;
@@ -70,7 +71,11 @@ public class NettyMQTTHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
String clientID = (String) NettyUtils.getAttribute(ctx, NettyChannel.ATTR_KEY_CLIENTID);
m_messaging.lostConnection(clientID);
if (clientID != null && !clientID.isEmpty()) {
//if the channel was of a correctly connected client, inform messagin
//else it was of a not completed CONNECT message
m_messaging.lostConnection(clientID);
}
ctx.close(/*false*/);
}
@@ -1,5 +1,4 @@
# Set root logger level to DEBUG and its only appender to A1.
#log4j.rootLogger=ERROR, A1
log4j.rootLogger=ERROR, stdout, file
#log4j.logger.org.eclipse.moquette=WARN