diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index cd0e74b85..5f2e0657c 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -237,6 +237,9 @@ local.media.storage.root media # 建议使用false server.multi_endpoint false +## 是否支持PC多端登陆,当server.multi_endpoint为true时,此开关无意义,当为false时,可以单独打开PC端多端登录。 +server.multi_pc_endpoint false + # 多平台连接状态通知(仅当multi_endpoint为false时有效),true时移动端可以收到pc或web端登录的通知。 server.multi_platform_notification true diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index 2ee3c5543..4f9bf6fa6 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -125,6 +125,7 @@ public final class BrokerConstants { public static final String SERVER_MULTI_ENDPOINT = "server.multi_endpoint"; + public static final String SERVER_MULTI_PC_ENDPOINT = "server.multi_pc_endpoint"; public static final String SERVER_MULTI_PLATFROM_NOTIFICATION = "server.multi_platform_notification"; public static final String SERVER_MOBILE_DEFAULT_SILENT_WHEN_PC_ONLINE = "server.mobile_default_silent_when_pc_online"; public static final String SERVER_CLIENT_SUPPORT_KICKOFF_EVENT = "server.client_support_kickoff_event"; diff --git a/broker/src/main/java/io/moquette/persistence/MemorySessionStore.java b/broker/src/main/java/io/moquette/persistence/MemorySessionStore.java index 8cb738e7b..457c616c3 100755 --- a/broker/src/main/java/io/moquette/persistence/MemorySessionStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemorySessionStore.java @@ -39,6 +39,7 @@ public class MemorySessionStore implements ISessionsStore { private static final Logger LOG = LoggerFactory.getLogger(MemorySessionStore.class); private boolean supportMultiEndpoint = false; + private boolean supportMultiPCEndpoint = false; private boolean clientSupportKickoff = false; public static class Session implements Comparable{ @@ -287,6 +288,11 @@ public MemorySessionStore(Server server, DatabaseStore databaseStore) { Utility.printExecption(LOG, e); } + try { + supportMultiPCEndpoint = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_PC_ENDPOINT, "false")); + } catch (Exception e) { + } + try { clientSupportKickoff = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_CLIENT_SUPPORT_KICKOFF_EVENT, "false")); } catch (Exception e) { @@ -385,7 +391,12 @@ public Session updateOrCreateUserSession(String username, String clientID, int p } databaseStore.clearMultiUser(username, clientID); - if (!supportMultiEndpoint && platform > 0) { + if (!supportMultiEndpoint + && platform > 0 + && !(platform == ProtoConstants.Platform.Platform_Windows && supportMultiPCEndpoint) + && !(platform == ProtoConstants.Platform.Platform_LINUX && supportMultiPCEndpoint) + && !(platform == ProtoConstants.Platform.Platform_OSX && supportMultiPCEndpoint) + ) { databaseStore.clearMultiEndpoint(username, clientID, platform); if (userSessions.get(username) != null) { Iterator it = userSessions.get(username).iterator(); diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index 8c7c15eca..029178fc5 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -232,6 +232,9 @@ local.media.storage.root ./media # 建议使用false server.multi_endpoint false +## 是否支持PC多端登陆,当server.multi_endpoint为true时,此开关无意义,当为false时,可以单独打开PC端多端登录。 +server.multi_pc_endpoint false + # 多平台连接状态通知(仅当multi_endpoint为false时有效),true时移动端可以收到pc或web端登录的通知。 server.multi_platform_notification true