Skip to content

Commit

Permalink
当关闭pc在线通知时可以清理掉历史在线状态
Browse files Browse the repository at this point in the history
  • Loading branch information
heavyrain2012 committed Dec 30, 2021
1 parent 1434daf commit c7dbf45
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,24 @@ public ErrorCode modifyUserInfo(String userId, WFCMessage.ModifyMyInfoRequest re

}

public void forceCleanOnlineStatus(String userId, String clientId) {
if (m_Server.isShutdowning()) {
return;
}

if(!mMultiPlatformNotification || m_Server.getStore().sessionsStore().isMultiEndpointSupported()) {
WFCMessage.UserSettingEntry pcentry = getUserSetting(userId, kUserSettingPCOnline, "PC");
if (pcentry != null && !StringUtil.isNullOrEmpty(pcentry.getValue()) && pcentry.getValue().contains(clientId)) {
updateUserSettings(userId, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), clientId);
}

WFCMessage.UserSettingEntry padentry = getUserSetting(userId, kUserSettingPCOnline, "Pad");
if (padentry != null && !StringUtil.isNullOrEmpty(padentry.getValue()) && padentry.getValue().contains(clientId)) {
updateUserSettings(userId, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue("").build(), clientId);
}
}
}

@Override
public void updateUserOnlineSetting(MemorySessionStore.Session session, boolean online) {
if(!mMultiPlatformNotification) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,8 @@ public ErrorCode kickoffPCClient(String operator, String pcClientId) {
if (session != null) {
if(!operator.equals(session.getUsername())) {
LOG.error("kickoffPCClient failure, user {} don't have client {}", operator, pcClientId);
return ErrorCode.ERROR_CODE_NOT_RIGHT;
mServer.getProcessor().getMessagesStore().forceCleanOnlineStatus(operator, pcClientId);
return ErrorCode.ERROR_CODE_SUCCESS;
}
if (session.getPlatform() == ProtoConstants.Platform.Platform_LINUX
|| session.getPlatform() == ProtoConstants.Platform.Platform_Windows
Expand All @@ -746,6 +747,7 @@ public ErrorCode kickoffPCClient(String operator, String pcClientId) {
}
} else {
LOG.error("Can't find the session for client <{}>", pcClientId);
mServer.getProcessor().getMessagesStore().forceCleanOnlineStatus(operator, pcClientId);
}
return ErrorCode.ERROR_CODE_SUCCESS;
}
Expand Down
2 changes: 2 additions & 0 deletions broker/src/main/java/io/moquette/spi/IMessagesStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public String toString() {

ErrorCode modifyUserInfo(String userId, WFCMessage.ModifyMyInfoRequest request) throws Exception;

void forceCleanOnlineStatus(String userId, String clientId);

void updateUserOnlineSetting(MemorySessionStore.Session session, boolean online);

ErrorCode modifyUserStatus(String userId, int status);
Expand Down

0 comments on commit c7dbf45

Please sign in to comment.