NIMSDK-AOS  9.19.0
CdnRequestData.java
浏览该文件的文档.
1 package com.netease.nimlib.sdk.chatroom.model;
2 
3 import android.os.Parcel;
4 import android.os.Parcelable;
5 
6 import com.netease.nimlib.chatroom.model.CdnURLRequestData;
7 
8 import org.json.JSONException;
9 import org.json.JSONObject;
10 
11 import java.io.Serializable;
12 import java.util.Map;
13 
14 public class CdnRequestData implements Serializable, Parcelable {
15 
16  /**
17  * host: cdn地址的host; success: 成功次数; fail: 失败次数;
18  * sr: 成功请求的平均回调耗时; fr: 失败清清的平均回调耗时
19  * sr: 成功请求的最大回调耗时; fr: 失败清清的最大回调耗时
20  * 格式: {
21  * host1: {success: 5, fail: 4, sr: 150, fr: 500, smr: 1500, fmr: 2000},
22  * host2: {...},
23  * ...
24  * }
25  */
26  private String urlReqData;
27 
28  /** 单个轮询周期内重试后最终失败的次数 */
29  private int failFinal;
30 
31  public CdnRequestData(Map<String, CdnURLRequestData> reqData, int failFinal) {
32  this.failFinal = failFinal;
33  if (reqData == null) {
34  return;
35  }
36  JSONObject dataObj = new JSONObject();
37  for (Map.Entry<String, CdnURLRequestData> entry : reqData.entrySet()) {
38  try {
39  dataObj.put(entry.getKey(), entry.getValue());
40  } catch (JSONException e) {
41  e.printStackTrace();
42  }
43  }
44  this.urlReqData = dataObj.toString();
45  }
46 
47  public String getUrlReqData() {
48  return urlReqData;
49  }
50 
51  public int getFailFinal() {
52  return failFinal;
53  }
54 
55  protected CdnRequestData(Parcel in) {
56  urlReqData = in.readString();
57  failFinal = in.readInt();
58  }
59 
60  public static final Creator<CdnRequestData> CREATOR = new Creator<CdnRequestData>() {
61  @Override
62  public CdnRequestData createFromParcel(Parcel in) {
63  return new CdnRequestData(in);
64  }
65 
66  @Override
67  public CdnRequestData[] newArray(int size) {
68  return new CdnRequestData[size];
69  }
70  };
71 
72  @Override
73  public int describeContents() {
74  return 0;
75  }
76 
77  @Override
78  public void writeToParcel(Parcel dest, int flags) {
79  dest.writeString(urlReqData);
80  dest.writeInt(failFinal);
81  }
82 }
CdnRequestData(Map< String, CdnURLRequestData > reqData, int failFinal)
static final Creator< CdnRequestData > CREATOR