From 6f5b021c898cccdbaeaebe3ca89f85ec1bffe72b Mon Sep 17 00:00:00 2001 From: heavyrian2012 Date: Thu, 6 Jan 2022 09:56:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9C=A8=E7=BA=BF=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/wildfirechat/push/PushServer.java | 8 ++------ .../imhandler/UploadDeviceTokenHandler.java | 2 +- .../io/moquette/persistence/DatabaseStore.java | 5 ----- .../persistence/MemoryMessagesStore.java | 16 ---------------- .../moquette/persistence/MemorySessionStore.java | 10 ++-------- .../io/moquette/spi/impl/MessagesPublisher.java | 4 +--- 6 files changed, 6 insertions(+), 39 deletions(-) diff --git a/broker/src/main/java/cn/wildfirechat/push/PushServer.java b/broker/src/main/java/cn/wildfirechat/push/PushServer.java index 48f69d753..b1099fc66 100644 --- a/broker/src/main/java/cn/wildfirechat/push/PushServer.java +++ b/broker/src/main/java/cn/wildfirechat/push/PushServer.java @@ -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(); } diff --git a/broker/src/main/java/io/moquette/imhandler/UploadDeviceTokenHandler.java b/broker/src/main/java/io/moquette/imhandler/UploadDeviceTokenHandler.java index 0403f5e4a..f8b777421 100644 --- a/broker/src/main/java/io/moquette/imhandler/UploadDeviceTokenHandler.java +++ b/broker/src/main/java/io/moquette/imhandler/UploadDeviceTokenHandler.java @@ -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 { diff --git a/broker/src/main/java/io/moquette/persistence/DatabaseStore.java b/broker/src/main/java/io/moquette/persistence/DatabaseStore.java index 07818d4e5..e852d8f1a 100644 --- a/broker/src/main/java/io/moquette/persistence/DatabaseStore.java +++ b/broker/src/main/java/io/moquette/persistence/DatabaseStore.java @@ -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"; } @@ -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); } diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index 43e2af885..48c06b181 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -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; @@ -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; } @@ -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 diff --git a/broker/src/main/java/io/moquette/persistence/MemorySessionStore.java b/broker/src/main/java/io/moquette/persistence/MemorySessionStore.java index f568fb9c7..dff5e2f35 100755 --- a/broker/src/main/java/io/moquette/persistence/MemorySessionStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemorySessionStore.java @@ -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; @@ -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); diff --git a/broker/src/main/java/io/moquette/spi/impl/MessagesPublisher.java b/broker/src/main/java/io/moquette/spi/impl/MessagesPublisher.java index d197409cd..433e1697e 100755 --- a/broker/src/main/java/io/moquette/spi/impl/MessagesPublisher.java +++ b/broker/src/main/java/io/moquette/spi/impl/MessagesPublisher.java @@ -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;