From 0f05d63a3baed1cf9a28f06375baf7b0a3b223d4 Mon Sep 17 00:00:00 2001 From: heavyrain lee Date: Fri, 19 Apr 2019 08:15:27 +0800 Subject: [PATCH] Add load history message function --- .../imhandler/LoadRemoteMessagesHandler.java | 30 + .../moquette/persistence/DatabaseStore.java | 69 ++ .../persistence/MemoryMessagesStore.java | 12 +- .../java/io/moquette/spi/IMessagesStore.java | 1 + .../src/main/java/win/liyufan/im/IMTopic.java | 2 + .../win/liyufan/im/MessageShardingUtil.java | 18 + .../cn/wildfirechat/proto/WFCMessage.java | 719 +++++++++++++++++- 7 files changed, 848 insertions(+), 3 deletions(-) create mode 100644 broker/src/main/java/io/moquette/imhandler/LoadRemoteMessagesHandler.java diff --git a/broker/src/main/java/io/moquette/imhandler/LoadRemoteMessagesHandler.java b/broker/src/main/java/io/moquette/imhandler/LoadRemoteMessagesHandler.java new file mode 100644 index 00000000..1fb288fb --- /dev/null +++ b/broker/src/main/java/io/moquette/imhandler/LoadRemoteMessagesHandler.java @@ -0,0 +1,30 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package io.moquette.imhandler; + +import cn.wildfirechat.proto.ProtoConstants; +import cn.wildfirechat.proto.WFCMessage; +import io.moquette.spi.impl.Qos1PublishHandler; +import io.netty.buffer.ByteBuf; +import win.liyufan.im.ErrorCode; +import win.liyufan.im.IMTopic; + +@Handler(value = IMTopic.LoadRemoteMessagesTopic) +public class LoadRemoteMessagesHandler extends IMHandler { + @Override + public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, WFCMessage.LoadRemoteMessages request, Qos1PublishHandler.IMCallback callback) { + ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS; + + WFCMessage.PullMessageResult result = m_messagesStore.loadRemoteMessages(fromUser, request.getConversation(), request.getBeforeUid(), request.getCount()); + byte[] data = result.toByteArray(); + LOG.info("User {} load message with count({}), payload size({})", fromUser, result.getMessageCount(), data.length); + ackPayload.ensureWritable(data.length).writeBytes(data); + return errorCode; + } +} diff --git a/broker/src/main/java/io/moquette/persistence/DatabaseStore.java b/broker/src/main/java/io/moquette/persistence/DatabaseStore.java index 635199f2..617fd073 100644 --- a/broker/src/main/java/io/moquette/persistence/DatabaseStore.java +++ b/broker/src/main/java/io/moquette/persistence/DatabaseStore.java @@ -8,6 +8,7 @@ package io.moquette.persistence; +import cn.wildfirechat.proto.ProtoConstants; import cn.wildfirechat.proto.WFCMessage; import cn.wildfirechat.server.ThreadPoolExecutorWrapper; import com.hazelcast.core.HazelcastInstance; @@ -532,6 +533,74 @@ public class DatabaseStore { return null; } + List loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count) { + List messages = loadRemoteMessagesFromTable(user, conversation, beforeUid, count, MessageShardingUtil.getMessageTable(beforeUid)); + if (messages != null && messages.size() < count) { + String nexTable = MessageShardingUtil.getPreviousMessageTable(beforeUid); + List nextMessages = loadRemoteMessagesFromTable(user, conversation, beforeUid, count-messages.size(), nexTable); + if (nextMessages != null) { + messages.addAll(nextMessages); + } + } + return messages; + } + + List loadRemoteMessagesFromTable(String user, WFCMessage.Conversation conversation, long beforeUid, int count, String table) { + String sql = "select `_from`, `_type`, `_target`, `_line`, `_data`, `_dt` from " + table +" where"; + if (conversation.getType() == ProtoConstants.ConversationType.ConversationType_Private) { + sql += " _type = ? and _line = ? and _mid > ? and ((_target = ? and _from = ?) or (_target = ? and _from = ?)"; + } else { + sql += " _type = ? and _line = ? and _mid > ? and _target = ?"; + } + + sql += " limit ?"; + + Connection connection = null; + PreparedStatement statement = null; + ResultSet resultSet = null; + List out = new ArrayList<>(); + try { + connection = DBUtil.getConnection(); + statement = connection.prepareStatement(sql); + int index = 1; + statement.setInt(index++, conversation.getType()); + statement.setInt(index++, conversation.getLine()); + statement.setLong(index++, beforeUid); + statement.setString(index++, conversation.getTarget()); + if (conversation.getType() == ProtoConstants.ConversationType.ConversationType_Private) { + statement.setString(index++, user); + statement.setString(index++, user); + statement.setString(index++, conversation.getTarget()); + } + statement.setInt(index++, count); + resultSet = statement.executeQuery(); + while (resultSet.next()) { + WFCMessage.Message.Builder builder = WFCMessage.Message.newBuilder(); + index = 1; + builder.setMessageId(resultSet.getLong(index++)); + builder.setFromUser(resultSet.getString(index++)); + WFCMessage.Conversation.Builder cb = WFCMessage.Conversation.newBuilder(); + cb.setType(resultSet.getInt(index++)); + cb.setTarget(resultSet.getString(index++)); + cb.setLine(resultSet.getInt(index++)); + builder.setConversation(cb.build()); + Blob blob = resultSet.getBlob(index++); + + WFCMessage.MessageContent messageContent = WFCMessage.MessageContent.parseFrom(blob.getBinaryStream()); + builder.setContent(messageContent); + builder.setServerTimestamp(resultSet.getTimestamp(index++).getTime()); + WFCMessage.Message message = builder.build(); + out.add(message); + } + } catch (SQLException | IOException e) { + e.printStackTrace(); + Utility.printExecption(LOG, e); + } finally { + DBUtil.closeDB(connection, statement, resultSet); + } + return null; + } + void persistUserMessage(final String userId, final long messageId, final long messageSeq) { mScheduler.execute(()->{ Connection connection = null; diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index c03af304..2092e114 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -155,7 +155,6 @@ public class MemoryMessagesStore implements IMessagesStore { IMap mIMap = hzInstance.getMap(MESSAGES_MAP); - MessageBundle messageBundle = new MessageBundle(message.getMessageId(), fromUser, fromClientId, message); if (message.getContent().getPersistFlag() == Transparent) { mIMap.put(message.getMessageId(), messageBundle, 10, TimeUnit.SECONDS); @@ -347,6 +346,17 @@ public class MemoryMessagesStore implements IMessagesStore { return builder.build(); } + @Override + public WFCMessage.PullMessageResult loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count) { + WFCMessage.PullMessageResult.Builder builder = WFCMessage.PullMessageResult.newBuilder(); + List messages = databaseStore.loadRemoteMessages(user, conversation, beforeUid, count); + builder.setCurrent(0).setHead(0); + if(messages != null) { + builder.addAllMessage(messages); + } + return builder.build(); + } + @Override public Collection getChatroomMembers(String chatroomId) { MultiMap chatroomMembers = m_Server.getHazelcastInstance().getMultiMap(CHATROOM_MEMBER_IDS); diff --git a/broker/src/main/java/io/moquette/spi/IMessagesStore.java b/broker/src/main/java/io/moquette/spi/IMessagesStore.java index 4bb74fce..f9b0ed6d 100755 --- a/broker/src/main/java/io/moquette/spi/IMessagesStore.java +++ b/broker/src/main/java/io/moquette/spi/IMessagesStore.java @@ -100,6 +100,7 @@ public interface IMessagesStore { WFCMessage.Message storeMessage(String fromUser, String fromClientId, WFCMessage.Message message); int getNotifyReceivers(String fromUser, WFCMessage.Message message, Set notifyReceivers); WFCMessage.PullMessageResult fetchMessage(String user, String exceptClientId, long fromMessageId, int pullType); + WFCMessage.PullMessageResult loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count); long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String userId, long messageId); WFCMessage.GroupInfo createGroup(String operator, WFCMessage.GroupInfo groupInfo, List memberList); ErrorCode addGroupMembers(String operator, String groupId, List memberList); diff --git a/broker/src/main/java/win/liyufan/im/IMTopic.java b/broker/src/main/java/win/liyufan/im/IMTopic.java index 91ee0d77..6f27f063 100755 --- a/broker/src/main/java/win/liyufan/im/IMTopic.java +++ b/broker/src/main/java/win/liyufan/im/IMTopic.java @@ -67,4 +67,6 @@ public interface IMTopic { String ChannelPullTopic = "CHP"; String GetTokenTopic = "GETTOKEN"; + + String LoadRemoteMessagesTopic = "LRM"; } diff --git a/broker/src/main/java/win/liyufan/im/MessageShardingUtil.java b/broker/src/main/java/win/liyufan/im/MessageShardingUtil.java index 47b387e5..15b0b3a6 100644 --- a/broker/src/main/java/win/liyufan/im/MessageShardingUtil.java +++ b/broker/src/main/java/win/liyufan/im/MessageShardingUtil.java @@ -60,4 +60,22 @@ public class MessageShardingUtil { year %= 3; return "t_messages_" + (year * 12 + month); } + + public static String getPreviousMessageTable(long mid) { + if (DBUtil.IsEmbedDB) { + return null; + } + + mid >>= (nodeIdWidth + rotateIdWidth); + Date date = new Date(mid + T201801010000); + int month = date.getMonth(); + int year = date.getYear(); + year %= 3; + month = month + 1; + if (month == 12) { + month = 0; + year = (year + 3 -1)%3; + } + return "t_messages_" + (year * 12 + month); + } } diff --git a/client/src/main/java/cn/wildfirechat/proto/WFCMessage.java b/client/src/main/java/cn/wildfirechat/proto/WFCMessage.java index e6fd119d..2c9d68bf 100644 --- a/client/src/main/java/cn/wildfirechat/proto/WFCMessage.java +++ b/client/src/main/java/cn/wildfirechat/proto/WFCMessage.java @@ -55783,6 +55783,707 @@ public final class WFCMessage { // @@protoc_insertion_point(class_scope:GetTokenRequest) } + public interface LoadRemoteMessagesOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required .Conversation conversation = 1; + /** + * required .Conversation conversation = 1; + */ + boolean hasConversation(); + /** + * required .Conversation conversation = 1; + */ + cn.wildfirechat.proto.WFCMessage.Conversation getConversation(); + /** + * required .Conversation conversation = 1; + */ + cn.wildfirechat.proto.WFCMessage.ConversationOrBuilder getConversationOrBuilder(); + + // required int64 before_uid = 2; + /** + * required int64 before_uid = 2; + */ + boolean hasBeforeUid(); + /** + * required int64 before_uid = 2; + */ + long getBeforeUid(); + + // required int32 count = 3; + /** + * required int32 count = 3; + */ + boolean hasCount(); + /** + * required int32 count = 3; + */ + int getCount(); + } + /** + * Protobuf type {@code LoadRemoteMessages} + */ + public static final class LoadRemoteMessages extends + com.google.protobuf.GeneratedMessage + implements LoadRemoteMessagesOrBuilder { + // Use LoadRemoteMessages.newBuilder() to construct. + private LoadRemoteMessages(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private LoadRemoteMessages(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final LoadRemoteMessages defaultInstance; + public static LoadRemoteMessages getDefaultInstance() { + return defaultInstance; + } + + public LoadRemoteMessages getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private LoadRemoteMessages( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + cn.wildfirechat.proto.WFCMessage.Conversation.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = conversation_.toBuilder(); + } + conversation_ = input.readMessage(cn.wildfirechat.proto.WFCMessage.Conversation.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(conversation_); + conversation_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 16: { + bitField0_ |= 0x00000002; + beforeUid_ = input.readInt64(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + count_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return cn.wildfirechat.proto.WFCMessage.internal_static_LoadRemoteMessages_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return cn.wildfirechat.proto.WFCMessage.internal_static_LoadRemoteMessages_fieldAccessorTable + .ensureFieldAccessorsInitialized( + cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages.class, cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public LoadRemoteMessages parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new LoadRemoteMessages(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required .Conversation conversation = 1; + public static final int CONVERSATION_FIELD_NUMBER = 1; + private cn.wildfirechat.proto.WFCMessage.Conversation conversation_; + /** + * required .Conversation conversation = 1; + */ + public boolean hasConversation() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .Conversation conversation = 1; + */ + public cn.wildfirechat.proto.WFCMessage.Conversation getConversation() { + return conversation_; + } + /** + * required .Conversation conversation = 1; + */ + public cn.wildfirechat.proto.WFCMessage.ConversationOrBuilder getConversationOrBuilder() { + return conversation_; + } + + // required int64 before_uid = 2; + public static final int BEFORE_UID_FIELD_NUMBER = 2; + private long beforeUid_; + /** + * required int64 before_uid = 2; + */ + public boolean hasBeforeUid() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int64 before_uid = 2; + */ + public long getBeforeUid() { + return beforeUid_; + } + + // required int32 count = 3; + public static final int COUNT_FIELD_NUMBER = 3; + private int count_; + /** + * required int32 count = 3; + */ + public boolean hasCount() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required int32 count = 3; + */ + public int getCount() { + return count_; + } + + private void initFields() { + conversation_ = cn.wildfirechat.proto.WFCMessage.Conversation.getDefaultInstance(); + beforeUid_ = 0L; + count_ = 0; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasConversation()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasBeforeUid()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasCount()) { + memoizedIsInitialized = 0; + return false; + } + if (!getConversation().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeMessage(1, conversation_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeInt64(2, beforeUid_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt32(3, count_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, conversation_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, beforeUid_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, count_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code LoadRemoteMessages} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements cn.wildfirechat.proto.WFCMessage.LoadRemoteMessagesOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return cn.wildfirechat.proto.WFCMessage.internal_static_LoadRemoteMessages_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return cn.wildfirechat.proto.WFCMessage.internal_static_LoadRemoteMessages_fieldAccessorTable + .ensureFieldAccessorsInitialized( + cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages.class, cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages.Builder.class); + } + + // Construct using cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getConversationFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (conversationBuilder_ == null) { + conversation_ = cn.wildfirechat.proto.WFCMessage.Conversation.getDefaultInstance(); + } else { + conversationBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + beforeUid_ = 0L; + bitField0_ = (bitField0_ & ~0x00000002); + count_ = 0; + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return cn.wildfirechat.proto.WFCMessage.internal_static_LoadRemoteMessages_descriptor; + } + + public cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages getDefaultInstanceForType() { + return cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages.getDefaultInstance(); + } + + public cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages build() { + cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages buildPartial() { + cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages result = new cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (conversationBuilder_ == null) { + result.conversation_ = conversation_; + } else { + result.conversation_ = conversationBuilder_.build(); + } + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.beforeUid_ = beforeUid_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.count_ = count_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages) { + return mergeFrom((cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages other) { + if (other == cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages.getDefaultInstance()) return this; + if (other.hasConversation()) { + mergeConversation(other.getConversation()); + } + if (other.hasBeforeUid()) { + setBeforeUid(other.getBeforeUid()); + } + if (other.hasCount()) { + setCount(other.getCount()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasConversation()) { + + return false; + } + if (!hasBeforeUid()) { + + return false; + } + if (!hasCount()) { + + return false; + } + if (!getConversation().isInitialized()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (cn.wildfirechat.proto.WFCMessage.LoadRemoteMessages) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required .Conversation conversation = 1; + private cn.wildfirechat.proto.WFCMessage.Conversation conversation_ = cn.wildfirechat.proto.WFCMessage.Conversation.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + cn.wildfirechat.proto.WFCMessage.Conversation, cn.wildfirechat.proto.WFCMessage.Conversation.Builder, cn.wildfirechat.proto.WFCMessage.ConversationOrBuilder> conversationBuilder_; + /** + * required .Conversation conversation = 1; + */ + public boolean hasConversation() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .Conversation conversation = 1; + */ + public cn.wildfirechat.proto.WFCMessage.Conversation getConversation() { + if (conversationBuilder_ == null) { + return conversation_; + } else { + return conversationBuilder_.getMessage(); + } + } + /** + * required .Conversation conversation = 1; + */ + public Builder setConversation(cn.wildfirechat.proto.WFCMessage.Conversation value) { + if (conversationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + conversation_ = value; + onChanged(); + } else { + conversationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .Conversation conversation = 1; + */ + public Builder setConversation( + cn.wildfirechat.proto.WFCMessage.Conversation.Builder builderForValue) { + if (conversationBuilder_ == null) { + conversation_ = builderForValue.build(); + onChanged(); + } else { + conversationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .Conversation conversation = 1; + */ + public Builder mergeConversation(cn.wildfirechat.proto.WFCMessage.Conversation value) { + if (conversationBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + conversation_ != cn.wildfirechat.proto.WFCMessage.Conversation.getDefaultInstance()) { + conversation_ = + cn.wildfirechat.proto.WFCMessage.Conversation.newBuilder(conversation_).mergeFrom(value).buildPartial(); + } else { + conversation_ = value; + } + onChanged(); + } else { + conversationBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .Conversation conversation = 1; + */ + public Builder clearConversation() { + if (conversationBuilder_ == null) { + conversation_ = cn.wildfirechat.proto.WFCMessage.Conversation.getDefaultInstance(); + onChanged(); + } else { + conversationBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** + * required .Conversation conversation = 1; + */ + public cn.wildfirechat.proto.WFCMessage.Conversation.Builder getConversationBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getConversationFieldBuilder().getBuilder(); + } + /** + * required .Conversation conversation = 1; + */ + public cn.wildfirechat.proto.WFCMessage.ConversationOrBuilder getConversationOrBuilder() { + if (conversationBuilder_ != null) { + return conversationBuilder_.getMessageOrBuilder(); + } else { + return conversation_; + } + } + /** + * required .Conversation conversation = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + cn.wildfirechat.proto.WFCMessage.Conversation, cn.wildfirechat.proto.WFCMessage.Conversation.Builder, cn.wildfirechat.proto.WFCMessage.ConversationOrBuilder> + getConversationFieldBuilder() { + if (conversationBuilder_ == null) { + conversationBuilder_ = new com.google.protobuf.SingleFieldBuilder< + cn.wildfirechat.proto.WFCMessage.Conversation, cn.wildfirechat.proto.WFCMessage.Conversation.Builder, cn.wildfirechat.proto.WFCMessage.ConversationOrBuilder>( + conversation_, + getParentForChildren(), + isClean()); + conversation_ = null; + } + return conversationBuilder_; + } + + // required int64 before_uid = 2; + private long beforeUid_ ; + /** + * required int64 before_uid = 2; + */ + public boolean hasBeforeUid() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required int64 before_uid = 2; + */ + public long getBeforeUid() { + return beforeUid_; + } + /** + * required int64 before_uid = 2; + */ + public Builder setBeforeUid(long value) { + bitField0_ |= 0x00000002; + beforeUid_ = value; + onChanged(); + return this; + } + /** + * required int64 before_uid = 2; + */ + public Builder clearBeforeUid() { + bitField0_ = (bitField0_ & ~0x00000002); + beforeUid_ = 0L; + onChanged(); + return this; + } + + // required int32 count = 3; + private int count_ ; + /** + * required int32 count = 3; + */ + public boolean hasCount() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required int32 count = 3; + */ + public int getCount() { + return count_; + } + /** + * required int32 count = 3; + */ + public Builder setCount(int value) { + bitField0_ |= 0x00000004; + count_ = value; + onChanged(); + return this; + } + /** + * required int32 count = 3; + */ + public Builder clearCount() { + bitField0_ = (bitField0_ & ~0x00000004); + count_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:LoadRemoteMessages) + } + + static { + defaultInstance = new LoadRemoteMessages(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:LoadRemoteMessages) + } + private static com.google.protobuf.Descriptors.Descriptor internal_static_AddFriendRequest_descriptor; private static @@ -56123,6 +56824,11 @@ public final class WFCMessage { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_GetTokenRequest_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_LoadRemoteMessages_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_LoadRemoteMessages_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -56273,8 +56979,11 @@ public final class WFCMessage { "version\030\t \001(\t\022\023\n\013sdk_version\030\n \001(\t\"D\n\rRo" + "uteResponse\022\014\n\004host\030\001 \002(\t\022\021\n\tlong_port\030\002", " \002(\005\022\022\n\nshort_port\030\003 \002(\005\"5\n\017GetTokenRequ" + - "est\022\017\n\007user_id\030\001 \002(\t\022\021\n\tclient_id\030\002 \002(\tB" + - "#\n\025cn.wildfirechat.protoB\nWFCMessage" + "est\022\017\n\007user_id\030\001 \002(\t\022\021\n\tclient_id\030\002 \002(\t\"" + + "\\\n\022LoadRemoteMessages\022#\n\014conversation\030\001 " + + "\002(\0132\r.Conversation\022\022\n\nbefore_uid\030\002 \002(\003\022\r" + + "\n\005count\030\003 \002(\005B#\n\025cn.wildfirechat.protoB\n" + + "WFCMessage" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -56689,6 +57398,12 @@ public final class WFCMessage { com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_GetTokenRequest_descriptor, new java.lang.String[] { "UserId", "ClientId", }); + internal_static_LoadRemoteMessages_descriptor = + getDescriptor().getMessageTypes().get(68); + internal_static_LoadRemoteMessages_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_LoadRemoteMessages_descriptor, + new java.lang.String[] { "Conversation", "BeforeUid", "Count", }); return null; } };