添加配置,处理多端同时加入聊天室的问题
This commit is contained in:
@@ -172,7 +172,7 @@ public final class BrokerConstants {
|
||||
public static final String CHATROOM_Participant_Idle_Time = "chatroom.participant_idle_time";
|
||||
public static final String CHATROOM_Rejoin_When_Active = "chatroom.rejoin_when_active";
|
||||
public static final String CHATROOM_Create_When_Not_Exist = "chatroom.create_when_not_exist";
|
||||
|
||||
public static final String CHATROOM_Kickoff_Other_Platform = "chatroom.kickoff_other_platform";
|
||||
|
||||
public static final String GROUP_Allow_Owner_Recall_Self_Msg = "group.allow_owner_recall_self_msg";
|
||||
public static final String GROUP_Allow_Manager_Recall_Self_Msg = "group.allow_manager_recall_self_msg";
|
||||
|
||||
@@ -166,6 +166,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private long mChatroomParticipantIdleTime = 900000;
|
||||
private boolean mChatroomRejoinWhenActive = true;
|
||||
private boolean mChatroomCreateWhenNotExist = true;
|
||||
private boolean mChatroomKickoffOtherPlatform = true;
|
||||
|
||||
private List<Integer> mForbiddenClientSendTypes = new ArrayList<>();
|
||||
private List<Integer> mBlackListExceptionTypes = new ArrayList<>();
|
||||
@@ -346,6 +347,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
printMissConfigLog(CHATROOM_Create_When_Not_Exist, mChatroomCreateWhenNotExist + "");
|
||||
}
|
||||
|
||||
try {
|
||||
mChatroomKickoffOtherPlatform = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CHATROOM_Kickoff_Other_Platform, "true"));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
mChatroomParticipantIdleTime = Long.parseLong(m_Server.getConfig().getProperty(CHATROOM_Participant_Idle_Time, "900000"));
|
||||
} catch (Exception e) {
|
||||
@@ -3563,9 +3570,25 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
}
|
||||
}
|
||||
|
||||
MultiMap<String, UserClientEntry> chatroomMembers = m_Server.getHazelcastInstance().getMultiMap(CHATROOM_MEMBER_IDS);
|
||||
String alreadyInChatroom = (String) m_Server.getHazelcastInstance().getMap(USER_CHATROOM).get(userId);
|
||||
if(alreadyInChatroom != null) {
|
||||
for (UserClientEntry userClientEntry : chatroomMembers.get(alreadyInChatroom)) {
|
||||
if(userClientEntry.userId.equals(userId)) {
|
||||
if(!chatroomId.equals(alreadyInChatroom) || !userClientEntry.clientId.equals(clientId)) {
|
||||
if(mChatroomKickoffOtherPlatform) {
|
||||
handleQuitChatroom(userId, userClientEntry.clientId, chatroomId);
|
||||
} else {
|
||||
return ErrorCode.ERROR_CODE_OTHER_CLIENT_ALREADY_IN_CHATROOM;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_Server.getStore().sessionsStore().getSession(clientId).refreshLastChatroomActiveTime();
|
||||
m_Server.getHazelcastInstance().getMap(USER_CHATROOM).put(userId, chatroomId);
|
||||
m_Server.getHazelcastInstance().getMultiMap(CHATROOM_MEMBER_IDS).put(chatroomId, new UserClientEntry(userId, clientId));
|
||||
chatroomMembers.put(chatroomId, new UserClientEntry(userId, clientId));
|
||||
|
||||
mWriteLock.lock();
|
||||
chatroomMessages.put(userId, new TreeMap<>());
|
||||
|
||||
Reference in New Issue
Block a user