修正在线状态问题

This commit is contained in:
heavyrian2012
2022-03-23 21:45:27 +08:00
parent a3f2623d7e
commit 806cd440e3
2 changed files with 20 additions and 9 deletions
@@ -620,19 +620,30 @@ public class ProtocolProcessor {
String username = NettyUtils.userName(channel);
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
if(session != null) {
processOffline(session, clearSession);
}
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
if(connectionDescriptors.removeConnection(oldConnDescr)) {
m_interceptor.notifyClientConnectionLost(clientID, username);
processOffline(session, clearSession, new Runnable() {
@Override
public void run() {
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
if(connectionDescriptors.removeConnection(oldConnDescr)) {
m_interceptor.notifyClientConnectionLost(clientID, username);
}
}
});
} else {
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
if(connectionDescriptors.removeConnection(oldConnDescr)) {
m_interceptor.notifyClientConnectionLost(clientID, username);
}
}
}
public void processOffline(MemorySessionStore.Session session, boolean clearSession) {
public void processOffline(MemorySessionStore.Session session, boolean clearSession, Runnable runnable) {
if(session != null) {
session.refreshLastActiveTime();
forwardOnlineStatusEvent(session.getUsername(), session.getClientID(), session.getPlatform(), clearSession ? UserOnlineStatus.LOGOUT : UserOnlineStatus.OFFLINE, session.getAppName());
if(runnable != null) {
runnable.run();
}
m_messagesStore.updateUserOnlineSetting(session, false);
}
}