添加配置,处理多端同时加入聊天室的问题
This commit is contained in:
@@ -172,6 +172,12 @@ chatroom.rejoin_when_active true
|
|||||||
## 当一个聊天室不存在时,如果有用户加入就自动创建
|
## 当一个聊天室不存在时,如果有用户加入就自动创建
|
||||||
chatroom.create_when_not_exist true
|
chatroom.create_when_not_exist true
|
||||||
|
|
||||||
|
## 一个用户同一时刻只能加入一个聊天室。
|
||||||
|
## 当一个客户端加入一个聊天室时,如果这个客户端已经加入另外一个聊天室了,会自动退出之前的聊天室。
|
||||||
|
## 当一个客户端加入一个聊天室时,如果这个用户的其他端已经加入一个聊天室了,kickoff_other_platform为true时会自动退出之前的聊天室,为false时会返回225的错误码。
|
||||||
|
## 当自动退出聊天室时,客户端不会收到任何通知,只是不会再收到消息。
|
||||||
|
chatroom.kickoff_other_platform true
|
||||||
|
|
||||||
## 是否允许群主不受限制地撤回自己发送的消息。false可以${message.recall_time_limit}撤回自己的消息;true可以撤回任意时间自己的消息。默认为true。
|
## 是否允许群主不受限制地撤回自己发送的消息。false可以${message.recall_time_limit}撤回自己的消息;true可以撤回任意时间自己的消息。默认为true。
|
||||||
group.allow_owner_recall_self_msg true
|
group.allow_owner_recall_self_msg true
|
||||||
|
|
||||||
|
|||||||
@@ -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_Participant_Idle_Time = "chatroom.participant_idle_time";
|
||||||
public static final String CHATROOM_Rejoin_When_Active = "chatroom.rejoin_when_active";
|
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_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_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";
|
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 long mChatroomParticipantIdleTime = 900000;
|
||||||
private boolean mChatroomRejoinWhenActive = true;
|
private boolean mChatroomRejoinWhenActive = true;
|
||||||
private boolean mChatroomCreateWhenNotExist = true;
|
private boolean mChatroomCreateWhenNotExist = true;
|
||||||
|
private boolean mChatroomKickoffOtherPlatform = true;
|
||||||
|
|
||||||
private List<Integer> mForbiddenClientSendTypes = new ArrayList<>();
|
private List<Integer> mForbiddenClientSendTypes = new ArrayList<>();
|
||||||
private List<Integer> mBlackListExceptionTypes = new ArrayList<>();
|
private List<Integer> mBlackListExceptionTypes = new ArrayList<>();
|
||||||
@@ -346,6 +347,12 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
printMissConfigLog(CHATROOM_Create_When_Not_Exist, mChatroomCreateWhenNotExist + "");
|
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 {
|
try {
|
||||||
mChatroomParticipantIdleTime = Long.parseLong(m_Server.getConfig().getProperty(CHATROOM_Participant_Idle_Time, "900000"));
|
mChatroomParticipantIdleTime = Long.parseLong(m_Server.getConfig().getProperty(CHATROOM_Participant_Idle_Time, "900000"));
|
||||||
} catch (Exception e) {
|
} 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.getStore().sessionsStore().getSession(clientId).refreshLastChatroomActiveTime();
|
||||||
m_Server.getHazelcastInstance().getMap(USER_CHATROOM).put(userId, chatroomId);
|
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();
|
mWriteLock.lock();
|
||||||
chatroomMessages.put(userId, new TreeMap<>());
|
chatroomMessages.put(userId, new TreeMap<>());
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ public enum ErrorCode {
|
|||||||
|
|
||||||
ERROR_CODE_FUNCTION_DISABLED(220, "function disabled"),
|
ERROR_CODE_FUNCTION_DISABLED(220, "function disabled"),
|
||||||
|
|
||||||
|
ERROR_CODE_OTHER_CLIENT_ALREADY_IN_CHATROOM(225, "other client already in chatroom"),
|
||||||
|
|
||||||
ERROR_CODE_CHANNEL_NO_EXIST(236, "channel no exist"),
|
ERROR_CODE_CHANNEL_NO_EXIST(236, "channel no exist"),
|
||||||
ERROR_CODE_CHANNEL_NO_SECRET(237, "channel no secret"),
|
ERROR_CODE_CHANNEL_NO_SECRET(237, "channel no secret"),
|
||||||
ERROR_CODE_USER_NOT_PREPARED(238, "user not prepared"),
|
ERROR_CODE_USER_NOT_PREPARED(238, "user not prepared"),
|
||||||
|
|||||||
@@ -170,6 +170,12 @@ chatroom.rejoin_when_active true
|
|||||||
## 当一个聊天室不存在时,如果有用户加入就自动创建
|
## 当一个聊天室不存在时,如果有用户加入就自动创建
|
||||||
chatroom.create_when_not_exist true
|
chatroom.create_when_not_exist true
|
||||||
|
|
||||||
|
## 一个用户同一时刻只能加入一个聊天室。
|
||||||
|
## 当一个客户端加入一个聊天室时,如果这个客户端已经加入另外一个聊天室了,会自动退出之前的聊天室。
|
||||||
|
## 当一个客户端加入一个聊天室时,如果这个用户的其他端已经加入一个聊天室了,kickoff_other_platform为true时会自动退出之前的聊天室,为false时会返回225的错误码。
|
||||||
|
## 当自动退出聊天室时,客户端不会收到任何通知,只是不会再收到消息。
|
||||||
|
chatroom.kickoff_other_platform true
|
||||||
|
|
||||||
## 是否允许群主不受限制地撤回自己发送的消息。false可以${message.recall_time_limit}撤回自己的消息;true可以撤回任意时间自己的消息。默认为true。
|
## 是否允许群主不受限制地撤回自己发送的消息。false可以${message.recall_time_limit}撤回自己的消息;true可以撤回任意时间自己的消息。默认为true。
|
||||||
group.allow_owner_recall_self_msg true
|
group.allow_owner_recall_self_msg true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user