为聊天室增加单独的允许拉取远程消息的开关
This commit is contained in:
@@ -65,6 +65,9 @@ message.remote_history_message 0
|
|||||||
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
||||||
message.max_queue 1024
|
message.max_queue 1024
|
||||||
|
|
||||||
|
##是否开启拉取聊天室远程历史消息。如果为1,可以下拉继续加载在服务器上的该聊天室的消息;如果为0则不能。默认为1
|
||||||
|
message.chatroom_remote_history_message 1
|
||||||
|
|
||||||
##是否禁止陌生人聊天
|
##是否禁止陌生人聊天
|
||||||
message.disable_stranger_chat false
|
message.disable_stranger_chat false
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ public final class BrokerConstants {
|
|||||||
|
|
||||||
public static final String MESSAGE_ROAMING = "message.roaming";
|
public static final String MESSAGE_ROAMING = "message.roaming";
|
||||||
public static final String MESSAGE_Remote_History_Message = "message.remote_history_message";
|
public static final String MESSAGE_Remote_History_Message = "message.remote_history_message";
|
||||||
|
public static final String MESSAGE_Remote_Chatroom_History_Message = "message.chatroom_remote_history_message";
|
||||||
|
|
||||||
public static final String MESSAGE_Max_Queue = "message.max_queue";
|
public static final String MESSAGE_Max_Queue = "message.max_queue";
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
private static boolean IS_MESSAGE_ROAMING = true;
|
private static boolean IS_MESSAGE_ROAMING = true;
|
||||||
|
|
||||||
private static boolean IS_MESSAGE_REMOTE_HISTORY_MESSAGE = true;
|
private static boolean IS_MESSAGE_REMOTE_HISTORY_MESSAGE = true;
|
||||||
|
private static boolean IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = true;
|
||||||
|
|
||||||
static final String USER_ROBOTS = "user_robots";
|
static final String USER_ROBOTS = "user_robots";
|
||||||
static final String USER_THINGS = "user_things";
|
static final String USER_THINGS = "user_things";
|
||||||
@@ -167,6 +168,7 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
|
|
||||||
IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING));
|
IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING));
|
||||||
IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message));
|
IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message));
|
||||||
|
IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_Chatroom_History_Message, "1"));
|
||||||
Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue));
|
Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -733,15 +735,22 @@ public class MemoryMessagesStore implements IMessagesStore {
|
|||||||
public WFCMessage.PullMessageResult loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count) {
|
public WFCMessage.PullMessageResult loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count) {
|
||||||
WFCMessage.PullMessageResult.Builder builder = WFCMessage.PullMessageResult.newBuilder();
|
WFCMessage.PullMessageResult.Builder builder = WFCMessage.PullMessageResult.newBuilder();
|
||||||
List<WFCMessage.Message> messages;
|
List<WFCMessage.Message> messages;
|
||||||
if (IS_MESSAGE_REMOTE_HISTORY_MESSAGE) {
|
boolean loadMessage = IS_MESSAGE_REMOTE_HISTORY_MESSAGE;
|
||||||
messages = databaseStore.loadRemoteMessages(user, conversation, beforeUid, count);
|
if(conversation.getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
||||||
} else {
|
loadMessage = IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE;
|
||||||
messages = new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loadMessage) {
|
||||||
|
messages = databaseStore.loadRemoteMessages(user, conversation, beforeUid, count);
|
||||||
|
} else {
|
||||||
|
messages = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
builder.setCurrent(0).setHead(0);
|
builder.setCurrent(0).setHead(0);
|
||||||
if(messages != null) {
|
if(messages != null) {
|
||||||
builder.addAllMessage(messages);
|
builder.addAllMessage(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ message.remote_history_message 0
|
|||||||
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
##服务器为每个用户缓存的消息数量。这个值改得太大,拉取消息时间变长,另外会占用大量内存。
|
||||||
message.max_queue 1024
|
message.max_queue 1024
|
||||||
|
|
||||||
|
##是否开启拉取聊天室远程历史消息。如果为1,可以下拉继续加载在服务器上的该聊天室的消息;如果为0则不能。默认为1
|
||||||
|
message.chatroom_remote_history_message 1
|
||||||
|
|
||||||
##是否禁止陌生人聊天
|
##是否禁止陌生人聊天
|
||||||
message.disable_stranger_chat false
|
message.disable_stranger_chat false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user