处理disconnect的在线状态

This commit is contained in:
heavyrian2012
2022-03-23 19:55:58 +08:00
parent 4bc5fd6bb9
commit a3f2623d7e
2 changed files with 8 additions and 2 deletions
@@ -751,6 +751,7 @@ public class MemorySessionStore implements ISessionsStore {
public void disableSession(String userId, String clientId) {
Session session = sessions.get(clientId);
if (session != null && session.getDeleted() == 0 && (userId == null || session.getUsername().equals(userId))) {
mServer.getProcessor().processOffline(session, false);
databaseStore.updateSessionDeleted(session.getUsername(), clientId, 1);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientId);
@@ -772,6 +773,7 @@ public class MemorySessionStore implements ISessionsStore {
return;
}
mServer.getProcessor().processOffline(session, true);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
sessionSet.remove(clientID);
@@ -620,15 +620,19 @@ public class ProtocolProcessor {
String username = NettyUtils.userName(channel);
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
if(session != null) {
session.refreshLastActiveTime();
forwardOnlineStatusEvent(username, clientID, session.getPlatform(), clearSession ? UserOnlineStatus.LOGOUT : UserOnlineStatus.OFFLINE, session.getAppName());
processOffline(session, clearSession);
}
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
if(connectionDescriptors.removeConnection(oldConnDescr)) {
m_interceptor.notifyClientConnectionLost(clientID, username);
}
}
public void processOffline(MemorySessionStore.Session session, boolean clearSession) {
if(session != null) {
session.refreshLastActiveTime();
forwardOnlineStatusEvent(session.getUsername(), session.getClientID(), session.getPlatform(), clearSession ? UserOnlineStatus.LOGOUT : UserOnlineStatus.OFFLINE, session.getAppName());
m_messagesStore.updateUserOnlineSetting(session, false);
}
}