当聊天室不存在时,加入聊天室自动创建聊天室
This commit is contained in:
@@ -123,6 +123,9 @@ chatroom.participant_idle_time 900000
|
|||||||
## 用户向聊天室发送消息,自动加入聊天室
|
## 用户向聊天室发送消息,自动加入聊天室
|
||||||
chatroom.rejoin_when_active true
|
chatroom.rejoin_when_active true
|
||||||
|
|
||||||
|
## 当一个聊天室不存在时,如果有用户加入就自动创建
|
||||||
|
chatroom.create_when_not_exist true
|
||||||
|
|
||||||
## 是否允许客户端发送操作群的自定义群通知消息
|
## 是否允许客户端发送操作群的自定义群通知消息
|
||||||
group.allow_client_custom_operation_notification true
|
group.allow_client_custom_operation_notification true
|
||||||
|
|
||||||
|
|||||||
@@ -152,6 +152,8 @@ 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 GROUP_Allow_Client_Custom_Operation_Notification = "group.allow_client_custom_operation_notification";
|
public static final String GROUP_Allow_Client_Custom_Operation_Notification = "group.allow_client_custom_operation_notification";
|
||||||
public static final String GROUP_Visible_Quit_Kickoff_Notification = "group.visible_quit_or_kickoff_notification";
|
public static final String GROUP_Visible_Quit_Kickoff_Notification = "group.visible_quit_or_kickoff_notification";
|
||||||
|
|||||||
@@ -137,6 +137,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 List<Integer> mForbiddenClientSendTypes = new ArrayList<>();
|
private List<Integer> mForbiddenClientSendTypes = new ArrayList<>();
|
||||||
private List<Integer> mBlackListExceptionTypes = new ArrayList<>();
|
private List<Integer> mBlackListExceptionTypes = new ArrayList<>();
|
||||||
@@ -245,6 +246,14 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
printMissConfigLog(CHATROOM_Rejoin_When_Active, mChatroomRejoinWhenActive + "");
|
printMissConfigLog(CHATROOM_Rejoin_When_Active, mChatroomRejoinWhenActive + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mChatroomCreateWhenNotExist = Boolean.parseBoolean(m_Server.getConfig().getProperty(BrokerConstants.CHATROOM_Create_When_Not_Exist));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
printMissConfigLog(CHATROOM_Create_When_Not_Exist, mChatroomCreateWhenNotExist + "");
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -3061,8 +3070,13 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
public ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId) {
|
public ErrorCode handleJoinChatroom(String userId, String clientId, String chatroomId) {
|
||||||
IMap<String, WFCMessage.ChatroomInfo> chatroomInfoMap = m_Server.getHazelcastInstance().getMap(CHATROOMS);
|
IMap<String, WFCMessage.ChatroomInfo> chatroomInfoMap = m_Server.getHazelcastInstance().getMap(CHATROOMS);
|
||||||
if (chatroomInfoMap == null || chatroomInfoMap.get(chatroomId) == null) {
|
if (chatroomInfoMap == null || chatroomInfoMap.get(chatroomId) == null) {
|
||||||
|
if(mChatroomCreateWhenNotExist) {
|
||||||
|
WFCMessage.ChatroomInfo.Builder builder = WFCMessage.ChatroomInfo.newBuilder().setTitle(chatroomId);
|
||||||
|
createChatroom(chatroomId, builder.build());
|
||||||
|
} else {
|
||||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ chatroom.participant_idle_time 900000
|
|||||||
## 用户向聊天室发送消息,自动加入聊天室
|
## 用户向聊天室发送消息,自动加入聊天室
|
||||||
chatroom.rejoin_when_active true
|
chatroom.rejoin_when_active true
|
||||||
|
|
||||||
|
## 当一个聊天室不存在时,如果有用户加入就自动创建
|
||||||
|
chatroom.create_when_not_exist true
|
||||||
|
|
||||||
## 是否允许客户端发送操作群的自定义群通知消息
|
## 是否允许客户端发送操作群的自定义群通知消息
|
||||||
group.allow_client_custom_operation_notification true
|
group.allow_client_custom_operation_notification true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user