Fixed bug in deletion of valid conn descriptor once different clients with same ID connects (issues #116 and #124)

This commit is contained in:
andsel
2015-12-27 13:19:16 +01:00
parent 571eaa1378
commit 163858e47b
7 changed files with 94 additions and 5 deletions
@@ -38,4 +38,23 @@ public class ConnectionDescriptor {
public String toString() {
return "ConnectionDescriptor{" + "clientID=" + clientID + ", cleanSession=" + cleanSession + '}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConnectionDescriptor that = (ConnectionDescriptor) o;
if (clientID != null ? !clientID.equals(that.clientID) : that.clientID != null) return false;
return !(session != null ? !session.equals(that.session) : that.session != null);
}
@Override
public int hashCode() {
int result = clientID != null ? clientID.hashCode() : 0;
result = 31 * result + (session != null ? session.hashCode() : 0);
return result;
}
}
@@ -73,4 +73,20 @@ public class NettyChannel implements ServerChannel {
String clientID = (String) getAttribute(ATTR_KEY_CLIENTID);
return "session [clientID: "+ clientID +"]";
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
NettyChannel that = (NettyChannel) o;
return !(m_channel != null ? !m_channel.channel().equals(that.m_channel.channel()) : that.m_channel != null);
}
@Override
public int hashCode() {
return m_channel != null ? m_channel.channel().hashCode() : 0;
}
}
@@ -96,7 +96,7 @@ public class NettyMQTTHandler extends ChannelInboundHandlerAdapter {
if (stolenAttr != null && stolenAttr == Boolean.TRUE) {
stolen = stolenAttr;
}
m_processor.processConnectionLost(clientID, stolen);
m_processor.processConnectionLost(clientID, stolen, new NettyChannel(ctx));
}
ctx.close();
}