Fixed missed clean session for ClientSession, issue #145
This commit is contained in:
@@ -55,7 +55,7 @@ public class ClientSession {
|
||||
|
||||
private Set<Subscription> subscriptions = new HashSet<>();
|
||||
|
||||
public final boolean cleanSession;
|
||||
private volatile boolean cleanSession;
|
||||
|
||||
private boolean active = false;
|
||||
|
||||
@@ -146,6 +146,11 @@ public class ClientSession {
|
||||
return this.cleanSession;
|
||||
}
|
||||
|
||||
public void cleanSession(boolean cleanSession) {
|
||||
this.cleanSession = cleanSession;
|
||||
this.m_sessionsStore.updateCleanStatus(this.clientID, cleanSession);
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
this.active = true;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import io.moquette.spi.impl.subscriptions.Subscription;
|
||||
*/
|
||||
public interface ISessionsStore {
|
||||
|
||||
void updateCleanStatus(String clientID, boolean cleanSession);
|
||||
|
||||
class ClientTopicCouple {
|
||||
public final String topicFilter;
|
||||
public final String clientID;
|
||||
@@ -99,6 +101,7 @@ public interface ISessionsStore {
|
||||
ClientSession createNewSession(String clientID, boolean cleanSession);
|
||||
|
||||
/**
|
||||
* @param clientID the client owning the session.
|
||||
* @return the session for the given clientID, null if not found.
|
||||
* */
|
||||
ClientSession sessionForClient(String clientID);
|
||||
|
||||
@@ -219,6 +219,9 @@ public class ProtocolProcessor {
|
||||
if (!msg.isCleanSession() && isSessionAlreadyStored) {
|
||||
okResp.setSessionPresent(true);
|
||||
}
|
||||
if (isSessionAlreadyStored) {
|
||||
clientSession.cleanSession(msg.isCleanSession());
|
||||
}
|
||||
channel.writeAndFlush(okResp);
|
||||
m_interceptor.notifyClientConnected(msg);
|
||||
|
||||
|
||||
@@ -143,6 +143,11 @@ class MapDBSessionsStore implements ISessionsStore {
|
||||
return new ClientSession(clientID, m_messagesStore, this, storedSession.cleanSession);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCleanStatus(String clientID, boolean cleanSession) {
|
||||
m_persistentSessions.put(clientID, new MapDBPersistentStore.PersistentSession(cleanSession));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next valid packetIdentifier for the given client session.
|
||||
* */
|
||||
|
||||
Reference in New Issue
Block a user