NIMSDK-AOS  9.19.0
RoamMsgHasMoreOption.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.msg.model;
2 
3 import android.text.TextUtils;
4 
5 import com.netease.nimlib.SDKCache;
6 import com.netease.nimlib.biz.constant.ITalkService;
7 import com.netease.nimlib.push.packet.marshal.Property;
9 
10 import java.io.Serializable;
11 
12 public class RoamMsgHasMoreOption implements Serializable {
13  /** 会话ID */
14  private final String sessionId;
15  /** 会话类型 */
16  private final SessionTypeEnum sessionType;
17  /** has more标记的消息的时间 */
18  private final long time;
19  /** has more标记的消息的服务ID */
20  private final long serverId;
21 
22  public RoamMsgHasMoreOption(String sessionId, SessionTypeEnum sessionTypeEnum, long time, long serverId) {
23  this.sessionId = sessionId;
24  this.sessionType = sessionTypeEnum;
25  this.time = time;
26  this.serverId = serverId;
27  }
28 
29  public RoamMsgHasMoreOption(Property msg) {
30  this.time = Long.parseLong(msg.get(ITalkService.Tag.time));
31  this.serverId = Long.parseLong(msg.get(ITalkService.Tag.msgid_server));
32 
33  String receiverType = msg.get(ITalkService.Tag.ReceiverType);
34  String toAccount = msg.get(ITalkService.Tag.ReceiverAccount);
35  String fromAccount = msg.get(ITalkService.Tag.fromAccount);
36  switch (receiverType){
37  case "1":
38  case "2":
39  this.sessionType = SessionTypeEnum.Team;
40  this.sessionId = toAccount;
41  break;
42  case "0":
43  default:
44  this.sessionType = SessionTypeEnum.P2P;
45  final String myAccId = SDKCache.getAccount();
46  this.sessionId = (myAccId != null && myAccId.equals(fromAccount)) ? toAccount : fromAccount;
47  break;
48  }
49  }
50 
51  public String getSessionId() {
52  return sessionId;
53  }
54 
56  return sessionType;
57  }
58 
59  public long getTime() {
60  return time;
61  }
62 
63  public long getServerId() {
64  return serverId;
65  }
66 
67  @Override
68  public String toString() {
69  return String.format("{sessionId: %s, sessionType: %s, time: %s, serverId: %s}", sessionId, sessionType, time, serverId);
70  }
71 }
RoamMsgHasMoreOption(String sessionId, SessionTypeEnum sessionTypeEnum, long time, long serverId)