处理disconnect的在线状态
This commit is contained in:
@@ -751,6 +751,7 @@ 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, false);
|
||||||
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);
|
||||||
@@ -772,6 +773,7 @@ public class MemorySessionStore implements ISessionsStore {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mServer.getProcessor().processOffline(session, true);
|
||||||
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
|
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(session.username);
|
||||||
sessionSet.remove(clientID);
|
sessionSet.remove(clientID);
|
||||||
|
|
||||||
|
|||||||
@@ -620,15 +620,19 @@ 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) {
|
||||||
session.refreshLastActiveTime();
|
processOffline(session, clearSession);
|
||||||
forwardOnlineStatusEvent(username, clientID, session.getPlatform(), clearSession ? UserOnlineStatus.LOGOUT : UserOnlineStatus.OFFLINE, session.getAppName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
|
ConnectionDescriptor oldConnDescr = new ConnectionDescriptor(clientID, channel);
|
||||||
if(connectionDescriptors.removeConnection(oldConnDescr)) {
|
if(connectionDescriptors.removeConnection(oldConnDescr)) {
|
||||||
m_interceptor.notifyClientConnectionLost(clientID, username);
|
m_interceptor.notifyClientConnectionLost(clientID, username);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processOffline(MemorySessionStore.Session session, boolean clearSession) {
|
||||||
if(session != null) {
|
if(session != null) {
|
||||||
|
session.refreshLastActiveTime();
|
||||||
|
forwardOnlineStatusEvent(session.getUsername(), session.getClientID(), session.getPlatform(), clearSession ? UserOnlineStatus.LOGOUT : UserOnlineStatus.OFFLINE, session.getAppName());
|
||||||
m_messagesStore.updateUserOnlineSetting(session, false);
|
m_messagesStore.updateUserOnlineSetting(session, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user