Skip to content

Commit

Permalink
解决在线逻辑错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
heavyrian2012 committed Jan 6, 2022
1 parent f8f225d commit 6f5b021
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 39 deletions.
8 changes: 2 additions & 6 deletions broker/src/main/java/cn/wildfirechat/push/PushServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,9 @@ private void pushMessageInternel(PushMessage pushMessage, String deviceId, Strin
pushMessage.deviceToken = session.getDeviceToken();
pushMessage.unReceivedMsg = badge;
pushMessage.userId = session.getUsername();
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS
|| session.getPlatform() == ProtoConstants.Platform.Platform_Android
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad
|| session.getPlatform() == ProtoConstants.Platform.Platform_APad) {
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS || session.getPlatform() == ProtoConstants.Platform.Platform_Android) {
String url = androidPushServerUrl;
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad) {
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS) {
url = iOSPushServerUrl;
pushMessage.voipDeviceToken = session.getVoipDeviceToken();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, Pr
MemorySessionStore.Session session = m_sessionsStore.getSession(clientID);
session.setPlatform(request.getPlatform());
session.setAppName(request.getAppName());
if ((request.getPlatform() == ProtoConstants.Platform.Platform_iOS || request.getPlatform() == ProtoConstants.Platform.Platform_iPad) && request.getPushType() == 2) {
if (request.getPlatform() == ProtoConstants.Platform.Platform_iOS && request.getPushType() == 2) {
session.setVoipDeviceToken(request.getDeviceToken());
m_sessionsStore.updateSessionToken(session, true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,6 @@ void clearMultiEndpoint(String uid, String clientId, int platform) {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
} else if(platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and (`_platform` = ? or `_platform` = ?) and `_cid` <> ? and `_deleted` = 0";
} else {
sql = "update t_user_session set `_deleted` = ?, `_token` = ?, `_voip_token` = ?, `_dt` = ? where `_uid`=? and `_platform` = ? and `_cid` <> ? and `_deleted` = 0";
}
Expand All @@ -1600,9 +1598,6 @@ void clearMultiEndpoint(String uid, String clientId, int platform) {
} else if(platform == ProtoConstants.Platform.Platform_iOS || platform == ProtoConstants.Platform.Platform_Android) {
statement.setInt(index++, ProtoConstants.Platform.Platform_iOS);
statement.setInt(index++, ProtoConstants.Platform.Platform_Android);
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
statement.setInt(index++, ProtoConstants.Platform.Platform_iPad);
statement.setInt(index++, ProtoConstants.Platform.Platform_APad);
} else {
statement.setInt(index++, platform);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2345,7 +2345,6 @@ public void updateUserOnlineSetting(MemorySessionStore.Session session, boolean
}

String pcValue = null;
String padValue = null;
for (MemorySessionStore.Session s : m_Server.getStore().sessionsStore().sessionForUser(session.username)) {
if (s.getDeleted() != 0 || !m_Server.getConnectionsManager().isConnected(s.getClientID())) {
continue;
Expand All @@ -2357,10 +2356,6 @@ public void updateUserOnlineSetting(MemorySessionStore.Session session, boolean
case Platform_OSX:
pcValue = System.currentTimeMillis() + "|" + s.getPlatform() + "|" + s.getClientID() + "|" + s.getPhoneName();
break;
case Platform_iPad:
case Platform_APad:
padValue = System.currentTimeMillis() + "|" + s.getPlatform() + "|" + s.getClientID() + "|" + s.getPhoneName();
break;
default:
break;
}
Expand All @@ -2376,17 +2371,6 @@ public void updateUserOnlineSetting(MemorySessionStore.Session session, boolean
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("PC").setValue("").build(), session.clientID);
}
}

WFCMessage.UserSettingEntry padentry = getUserSetting(session.getUsername(), kUserSettingPCOnline, "Pad");
if (padValue != null) {
if (padentry == null || StringUtil.isNullOrEmpty(padentry.getValue())) {
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue(padValue).build(), session.clientID);
}
} else {
if (padentry != null && !StringUtil.isNullOrEmpty(padentry.getValue())) {
updateUserSettings(session.username, WFCMessage.ModifyUserSettingReq.newBuilder().setScope(kUserSettingPCOnline).setKey("Pad").setValue("").build(), session.clientID);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,6 @@ public Session updateOrCreateUserSession(String username, String clientID, int p
if (s.getPlatform() == ProtoConstants.Platform.Platform_OSX || s.getPlatform() == ProtoConstants.Platform.Platform_Windows || platform == ProtoConstants.Platform.Platform_LINUX) {
remove = true;
}
} else if(platform == ProtoConstants.Platform.Platform_iPad || platform == ProtoConstants.Platform.Platform_APad) {
if (s.getPlatform() == ProtoConstants.Platform.Platform_iPad || s.getPlatform() == ProtoConstants.Platform.Platform_APad) {
remove = true;
}
} else {
if (s.getPlatform() ==platform) {
remove = true;
Expand Down Expand Up @@ -733,11 +729,9 @@ public ErrorCode kickoffPCClient(String operator, String pcClientId) {
return ErrorCode.ERROR_CODE_SUCCESS;
}
if (session.getPlatform() == ProtoConstants.Platform.Platform_LINUX
|| session.getPlatform() == ProtoConstants.Platform.Platform_WEB
|| session.getPlatform() == ProtoConstants.Platform.Platform_Windows
|| session.getPlatform() == ProtoConstants.Platform.Platform_OSX
|| session.getPlatform() == ProtoConstants.Platform.Platform_iPad
|| session.getPlatform() == ProtoConstants.Platform.Platform_APad
) {
|| session.getPlatform() == ProtoConstants.Platform.Platform_OSX) {
databaseStore.updateSessionDeleted(operator, pcClientId, 1);
sessions.remove(pcClientId);
mServer.getProcessor().kickoffSession(session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@ private void publish2Receivers(String sender, int conversationType, String targe
if (targetSession.getPlatform() == ProtoConstants.Platform.Platform_WEB
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_Windows
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_LINUX
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_OSX
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_iPad
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_APad) {
|| targetSession.getPlatform() == ProtoConstants.Platform.Platform_OSX) {
boolean targetIsActive = this.connectionDescriptors.isConnected(targetSession.getClientSession().clientID);
if (targetIsActive) {
isPcOnline = true;
Expand Down

0 comments on commit 6f5b021

Please sign in to comment.