添加开关

1,是否不转发管理员消息
2,客户端是否支持kickoff事件
This commit is contained in:
heavyrain2012
2021-09-07 22:07:54 +08:00
parent 92c9d761ed
commit eeaa9eefdf
5 changed files with 55 additions and 5 deletions
@@ -39,6 +39,7 @@ public class MemorySessionStore implements ISessionsStore {
private static final Logger LOG = LoggerFactory.getLogger(MemorySessionStore.class);
private boolean supportMultiEndpoint = false;
private boolean clientSupportKickoff = false;
public static class Session implements Comparable<Session>{
final String clientID;
@@ -280,7 +281,14 @@ public class MemorySessionStore implements ISessionsStore {
this.databaseStore = databaseStore;
try {
supportMultiEndpoint = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_ENDPOINT));
supportMultiEndpoint = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_MULTI_ENDPOINT, "false"));
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
}
try {
clientSupportKickoff = Boolean.parseBoolean(server.getConfig().getProperty(BrokerConstants.SERVER_CLIENT_SUPPORT_KICKOFF_EVENT, "false"));
} catch (Exception e) {
e.printStackTrace();
Utility.printExecption(LOG, e);
@@ -456,20 +464,32 @@ public class MemorySessionStore implements ISessionsStore {
if (session != null && session.getDeleted() == 0) {
LOG.error("already exists a session for client <{}>, bad condition", clientID);
throw new IllegalArgumentException("Can't create a session with the ID of an already existing" + clientID);
return ErrorCode.ERROR_CODE_SUCCESS;
}
if (session != null && session.getDeleted() > 0) {
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
if(clientSupportKickoff) {
return ErrorCode.ERROR_CODE_KICKED_OFF;
} else {
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
}
}
ClientSession clientSession = new ClientSession(clientID, this);
session = databaseStore.getSession(username, clientID, clientSession);
if (session == null || session.getDeleted() > 0) {
if (session == null) {
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
}
if(session.getDeleted() > 0) {
if(clientSupportKickoff) {
return ErrorCode.ERROR_CODE_KICKED_OFF;
} else {
return ErrorCode.ERROR_CODE_SECRECT_KEY_MISMATCH;
}
}
sessions.put(clientID, session);
ConcurrentSkipListSet<String> sessionSet = getUserSessionSet(username);
sessionSet.add(clientID);