From bc6189c65efc551e0990fd26a190cc600010bb36 Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Fri, 10 Aug 2012 20:57:36 +0200 Subject: [PATCH] Fixed the clean session once a new connect with an old client ID is re-established --- .../java/org/dna/mqtt/moquette/server/MQTTHandler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/parser/src/main/java/org/dna/mqtt/moquette/server/MQTTHandler.java b/parser/src/main/java/org/dna/mqtt/moquette/server/MQTTHandler.java index a6d05a98..d79a732e 100644 --- a/parser/src/main/java/org/dna/mqtt/moquette/server/MQTTHandler.java +++ b/parser/src/main/java/org/dna/mqtt/moquette/server/MQTTHandler.java @@ -79,7 +79,14 @@ public class MQTTHandler extends IoHandlerAdapter implements INotifier { //if an old client with the same ID already exists close its session. if (m_clientIDs.containsKey(msg.getClientID())) { - //TODO also clean the subscriptions if it was in cleanSession = true + //clean the subscriptions if the old used a cleanSession = true + IoSession oldSession = m_clientIDs.get(msg.getClientID()).getSession(); + boolean cleanSession = (Boolean) oldSession.getAttribute("cleanSession"); + if (cleanSession) { + //cleanup topic subscriptions + m_messaging.removeSubscriptions(msg.getClientID()); + } + m_clientIDs.get(msg.getClientID()).getSession().close(false); }