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