在线状态

This commit is contained in:
heavyrian2012
2022-03-24 09:49:18 +08:00
parent def048836f
commit c0703332d6
2 changed files with 24 additions and 25 deletions
@@ -751,11 +751,12 @@ public class MemorySessionStore implements ISessionsStore {
public void disableSession(String userId, String clientId) { public void disableSession(String userId, String clientId) {
Session session = sessions.get(clientId); Session session = sessions.get(clientId);
if (session != null && session.getDeleted() == 0 && (userId == null || session.getUsername().equals(userId))) { if (session != null && session.getDeleted() == 0 && (userId == null || session.getUsername().equals(userId))) {
mServer.getProcessor().processOffline(session, true, null); mServer.getProcessor().processOffline(session, true, () -> {
databaseStore.updateSessionDeleted(session.getUsername(), clientId, 1); databaseStore.updateSessionDeleted(session.getUsername(), clientId, 1);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username); ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientId); sessionSet.remove(clientId);
sessions.remove(clientId); sessions.remove(clientId);
});
} }
} }
@@ -773,24 +774,25 @@ public class MemorySessionStore implements ISessionsStore {
return; return;
} }
mServer.getProcessor().processOffline(session, true, null); mServer.getProcessor().processOffline(session, true, () -> {
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username); ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientID); sessionSet.remove(clientID);
// remove also the messages stored of type QoS1/2 // remove also the messages stored of type QoS1/2
LOG.info("Removing stored messages with QoS 1 and 2. ClientId={}", clientID); LOG.info("Removing stored messages with QoS 1 and 2. ClientId={}", clientID);
session.secondPhaseStore.clear(); session.secondPhaseStore.clear();
session.outboundFlightMessages.clear(); session.outboundFlightMessages.clear();
session.inboundFlightMessages.clear(); session.inboundFlightMessages.clear();
LOG.info("Wiping existing subscriptions. ClientId={}", clientID); LOG.info("Wiping existing subscriptions. ClientId={}", clientID);
//remove also the enqueued messages //remove also the enqueued messages
dropQueue(clientID); dropQueue(clientID);
// TODO this missing last step breaks the junit test // TODO this missing last step breaks the junit test
sessions.remove(clientID); sessions.remove(clientID);
});
} }
@Override @Override
public boolean isMultiEndpointSupported() { public boolean isMultiEndpointSupported() {
@@ -620,13 +620,10 @@ public class ProtocolProcessor {
String username = NettyUtils.userName(channel); String username = NettyUtils.userName(channel);
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID); MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
if(session != null) { if(session != null) {
processOffline(session, clearSession, new Runnable() { processOffline(session, clearSession, () -> {
@Override ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
public void run() { if(connectionDescriptors.removeConnection(oldConnDescr)) {
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel); m_interceptor.notifyClientConnectionLost(clientID, username);
if(connectionDescriptors.removeConnection(oldConnDescr)) {
m_interceptor.notifyClientConnectionLost(clientID, username);
}
} }
}); });
} else { } else {