Skip to content

Commit

Permalink
添加允许pc多端的配置
Browse files Browse the repository at this point in the history
  • Loading branch information
heavyrian2012 committed Jun 6, 2022
1 parent 556e6ad commit dd40b72
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions broker/config/wildfirechat.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions broker/src/main/java/io/moquette/BrokerConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Session>{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<String> it = userSessions.get(username).iterator();
Expand Down
3 changes: 3 additions & 0 deletions distribution/src/main/resources/wildfirechat.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit dd40b72

Please sign in to comment.