12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using LitJson;
- using UnityEngine;
- public class ShowCommentsHttp
- {
- public bool disable;
- private Action<object> succeedCallback;
- private Action failedCallback;
- public void Callback(JsonData data)
- {
- //Debug.Log(data.ToJson());
- if (disable)
- {
- return;
- }
- bool succeed = data.Inst_Object.ContainsKey("list");
- if (succeed == false)
- {
- if (failedCallback != null)
- failedCallback.Invoke();
- }
- else
- {
- List<ShowCommentData> commentDatas = new List<ShowCommentData>();
- JsonData listData = data["list"];
- for (int i = 0; i < listData.Count; i++)
- {
- //Debug.Log(listData[i].ToJson());
- ShowCommentData commentData = new ShowCommentData(listData[i]);
- commentDatas.Add(commentData);
- }
- //Debug.Log(commentDatas.Count);
- if (succeedCallback != null)
- succeedCallback.Invoke(commentDatas);
- }
- }
- public void Callback(string str)
- {
- Debug.Log(str);
- }
- public static void Test()
- {
- Get(0, 46, null, null);
- }
- public static void Get(int page, int showId, Action<object> succeedCallback, Action failedCallback)
- {
- ShowCommentsHttp http = new ShowCommentsHttp();
- http.succeedCallback = succeedCallback;
- http.failedCallback = failedCallback;
- URLRequestData requestData = new URLRequestData();
- requestData.Add("p", page);
- requestData.Add("s", showId);
- URLRequest.CreateURLRequest(true, HttpManager.GetShowCommentListURL, requestData,
- http.Callback, URLRequest.Method.POST);
- //URLRequest.CreateStrURLRequest(true, HttpManager.GetShowCommentListURL, requestData,
- // http.Callback, URLRequest.Method.POST);
- }
- }
|