NIMSDK-AOS  10.6.0
MessageKey.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.msg.model;
2 
3 import com.netease.nimlib.biz.constant.ITalkService;
4 import com.netease.nimlib.push.packet.marshal.Property;
6 import com.netease.nimlib.util.StringUtil;
7 
8 import java.io.Serializable;
9 
17 public class MessageKey implements Serializable {
18  private final SessionTypeEnum sessionType;
19  private final String fromAccount;
20  private final String toAccount;
21  private final long time;
22  private final long serverId;
23  private final String uuid;
24 
25  public MessageKey(SessionTypeEnum sessionType, String fromAccount, String toAccount, long time, long serverId, String uuid) {
26  this.sessionType = sessionType;
27  this.fromAccount = fromAccount;
28  this.toAccount = toAccount;
29  this.time = time;
30  this.serverId = serverId;
31  this.uuid = uuid;
32  }
33 
34  public MessageKey(Property property) {
35  this.sessionType = SessionTypeEnum.typeOfValue(property.getInteger(ITalkService.Tag.ReceiverType));
36  this.fromAccount = property.get(ITalkService.Tag.fromAccount);
37  this.toAccount = property.get(ITalkService.Tag.ReceiverAccount);
38  this.time = property.getLong(ITalkService.Tag.time);
39  this.serverId = property.getLong(ITalkService.Tag.msgid_server);
40  this.uuid = property.get(ITalkService.Tag.msgid_client);
41  }
42 
44  return sessionType;
45  }
46 
47  public String getFromAccount() {
48  return fromAccount;
49  }
50 
51  public String getToAccount() {
52  return toAccount;
53  }
54 
55  public long getTime() {
56  return time;
57  }
58 
59  public long getServerId() {
60  return serverId;
61  }
62 
63  public String getUuid() {
64  return uuid;
65  }
66 
67  public boolean isValid() {
68  if (sessionType != SessionTypeEnum.P2P && sessionType != SessionTypeEnum.Team && sessionType != SessionTypeEnum.SUPER_TEAM) {
69  return false;
70  }
71  if (fromAccount == null) {
72  return false;
73  }
74  if (toAccount == null) {
75  return false;
76  }
77  if (time <= 0) {
78  return false;
79  }
80  if (serverId < 0) {
81  return false;
82  }
83  if (StringUtil.isEmpty(uuid)) {
84  return false;
85  }
86  return true;
87  }
88 
89  @Override
90  public String toString() {
91  return "MessageKey{" +
92  "sessionType=" + sessionType +
93  ", fromAccount='" + fromAccount + '\'' +
94  ", toAccount='" + toAccount + '\'' +
95  ", time=" + time +
96  ", serverId=" + serverId +
97  ", uuid='" + uuid + '\'' +
98  '}';
99  }
100 }
消息的关键信息,通过这些信息可以从服务端查询到该消息的完整部分
Definition: MessageKey.java:17
MessageKey(SessionTypeEnum sessionType, String fromAccount, String toAccount, long time, long serverId, String uuid)
Definition: MessageKey.java:25