NIMSDK-AOS  9.19.0
ChatRoomCdnInfo.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.chatroom.model;
2 
3 import android.os.Parcel;
4 import android.os.Parcelable;
5 
6 import java.io.Serializable;
7 
8 public class ChatRoomCdnInfo implements Serializable, Parcelable {
9  /** 是否开启CDN轮询,0表示关闭,1表示开启,默认关闭 */
10  boolean enable = false;
11 
12  /**
13  * cdn的轮询地址,|分隔,每个表示一个CDN的请求url,每个url是一个匹配串,如下:
14  * 如:https://chat-msg-activity.netease.im/abcdefg_#time,端侧需要将#time替换成当前时间戳,时间戳需要跟服务器时间戳对齐,防止本地时间不准的情况
15  * 端侧要自己起一个定时器,以下发的服务器时间戳为当前时间,计算轮询时的完整url
16  * cdn中的#time计算方法:(timestamp / (pollingIntervalSeconds*1000L)) * (pollingIntervalSeconds*1000L),即取整的pollingIntervalSeconds秒
17  */
18  String[] cdnUrlArray;
19 
20  /** 服务器当前时间戳,单位毫秒 */
21  long timestamp;
22 
23  /** 轮询间隔 ms */
24  long pollingInterval;
25 
26  /** 解密key */
27  String decryptKey;
28 
29  /** 请求超时 ms */
30  int timeOut;
31 
32  public ChatRoomCdnInfo() {
33  }
34 
35  public boolean isEnable() {
36  return enable;
37  }
38 
39  public void setEnable(boolean enable) {
40  this.enable = enable;
41  }
42 
43  public String[] getCdnUrlArray() {
44  return cdnUrlArray;
45  }
46 
47  public void setCdnUrlArray(String[] cdnUrlArray) {
48  this.cdnUrlArray = cdnUrlArray;
49  }
50 
51  public long getTimestamp() {
52  return timestamp;
53  }
54 
55  public void setTimestamp(long timestamp) {
56  this.timestamp = timestamp;
57  }
58 
59  public long getPollingInterval() {
60  return pollingInterval;
61  }
62 
63  public void setPollingInterval(long pollingInterval) {
64  this.pollingInterval = pollingInterval;
65  }
66 
67  public String getDecryptKey() {
68  return decryptKey;
69  }
70 
71  public void setDecryptKey(String decryptKey) {
72  this.decryptKey = decryptKey;
73  }
74 
75  public int getTimeOut() {
76  return timeOut;
77  }
78 
79  public void setTimeOut(int timeOut) {
80  this.timeOut = timeOut;
81  }
82 
84  ChatRoomCdnInfo newInstance = new ChatRoomCdnInfo();
85  newInstance.setEnable(enable);
86  newInstance.setCdnUrlArray(cdnUrlArray);
87  newInstance.setTimestamp(timestamp);
88  newInstance.setPollingInterval(pollingInterval);
89  newInstance.setDecryptKey(decryptKey);
90  newInstance.setTimeOut(timeOut);
91  return newInstance;
92  }
93 
94  /**
95  * ********************************** 序列化 **********************************
96  */
97  protected ChatRoomCdnInfo(Parcel in) {
98  enable = in.readInt() == 1;
99  in.readStringArray(cdnUrlArray);
100  timestamp = in.readLong();
101  pollingInterval = in.readLong();
102  decryptKey = in.readString();
103  timeOut = in.readInt();
104  }
105 
106  @Override
107  public int describeContents() {
108  return 0;
109  }
110 
111  @Override
112  public void writeToParcel(Parcel dest, int flags) {
113  dest.writeInt(enable ? 1 : 0);
114  dest.writeStringArray(cdnUrlArray);
115  dest.writeLong(timestamp);
116  dest.writeLong(pollingInterval);
117  dest.writeString(decryptKey);
118  dest.writeInt(timeOut);
119  }
120 
121  public static final Creator<ChatRoomCdnInfo> CREATOR = new Creator<ChatRoomCdnInfo>() {
122  @Override
123  public ChatRoomCdnInfo createFromParcel(Parcel in) {
124  return new ChatRoomCdnInfo(in);
125  }
126 
127  @Override
128  public ChatRoomCdnInfo[] newArray(int size) {
129  return new ChatRoomCdnInfo[size];
130  }
131  };
132 }
static final Creator< ChatRoomCdnInfo > CREATOR
ChatRoomCdnInfo(Parcel in)
********************************** 序列化 **********************************