1 package com.netease.nimlib.sdk.msg.model;
3 import androidx.annotation.NonNull;
4 import androidx.annotation.Nullable;
12 import java.io.Serializable;
22 private final String sessionId;
31 private long fromTime;
43 private long anchorServerId;
48 private String anchorClientId;
66 this.sessionId = sessionId;
67 this.sessionType = sessionType;
68 this.fromTime = fromTime;
70 this.anchorServerId = anchorServerId;
71 this.anchorClientId = anchorClientId;
73 this.direction = direction;
91 this.fromTime = fromTime;
103 return anchorServerId;
107 this.anchorServerId = anchorServerId;
111 return anchorClientId;
115 this.anchorClientId = anchorClientId;
131 this.direction = direction;
140 if (StringUtil.isNotEmpty(clientId)) {
141 IMMessage anchor = MsgDBHelper.queryMessageByUuid(clientId);
142 if (anchor instanceof IMMessageImpl) {
154 String formedSessionId = this.sessionId;
156 long formedFromTime = this.fromTime;
157 long formedToTime = this.toTime;
158 long formedExcludeServerId = this.anchorServerId;
159 String formedExcludeClientId = this.anchorClientId;
160 int formedLimit = this.limit;
164 return new GetMessagesDynamicallyParam(formedSessionId, formedSessionType, formedFromTime, formedToTime, formedExcludeServerId, formedExcludeClientId, formedLimit, formedDirection);
173 return StringUtil.isNotEmpty(sessionId)
177 && limit >= 0 && limit <= MAX_LIMIT
178 && (anchorServerId == 0 || StringUtil.isNotEmpty(anchorClientId));
183 return "GetMessagesDynamicallyParam{" +
184 "sessionId='" + sessionId +
'\'' +
185 ", sessionType=" + sessionType +
186 ", fromTime=" + fromTime +
187 ", toTime=" + toTime +
188 ", excludeServerId=" + anchorServerId +
189 ", excludeClientId='" + anchorClientId +
'\'' +
191 ", direction=" + direction +
void setAnchorServerId(long anchorServerId)
void setFromTime(long fromTime)
云信 IM 消息构造器,提供构建各类型消息的接口。
void setAnchorClientId(String anchorClientId)
String getAnchorClientId()
NIM消息实体数据结构。 第三方APP不要调用设置类接口,调用之后不会被持久化
GetMessageDirectionEnum getDirection()
static final int MAX_LIMIT
最大数量限制
static IMMessage createEmptyMessage(String sessionId, SessionTypeEnum sessionType, long time)
创建一条空消息。
boolean isValid()
参数合法的初阶判断函数
GetMessagesDynamicallyParam createStandardizedParam()
void setToTime(long toTime)
GetMessagesDynamicallyParam(@NonNull String sessionId, @NonNull SessionTypeEnum sessionType, long fromTime, long toTime, long anchorServerId, String anchorClientId, int limit, @Nullable GetMessageDirectionEnum direction)
void setDirection(GetMessageDirectionEnum direction)
IMMessage getAnchor()
可能会查询数据库
GetMessagesDynamicallyParam(@NonNull String sessionId, @NonNull SessionTypeEnum sessionType)
SessionTypeEnum getSessionType()