/// <summary>
 /// 添加请求
 /// </summary>
 /// <param name="commandId">后端的接口名称</param>
 /// <param name="param">需要传递的参数</param>
 /// <param name="resultBack">结果委托</param>
 public void AddRequest(string commandId, List<object> param, HttpNetResultDelegate resultBack = null)
 {
     ArrayList data = new ArrayList(3);
     data.Add(commandId);
     data.Add(param);
     data.Add(resultBack);
     groupData.Enqueue(data);
 }
示例#2
0
        /// <summary>
        /// 请求http,单一发送,不需求得到结果处理
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        IEnumerator PostSingle(string commandId, string url, HttpNetResultDelegate resultBack)
        {
            Debug.Log("singlePost>>:" + url);
            WWW www = new WWW(url);
            yield return www;
            if (resultBack != null)
            {
                resultBack(commandId, NetworkDataParser.RESPONSE_CODE_RESULT_SUCCESS, www.text);
            }

            Debug.Log("singlePost<< " + url + ":" + www.text);
        }
示例#3
0
 /// <summary>
 /// 发送一对一请求
 /// </summary>
 /// <param name="commandId"></param>
 /// <param name="args"></param>
 /// <param name="resultBack"></param>
 /// <param name="url"></param>
 void SendOneToOne(string commandId, List<object> args, HttpNetResultDelegate resultBack, string url)
 {
     if (url == null) url = requestURL;
     string URL = queueDataGroup.OneToOnePostDataPack(commandId, args, serverTime, url);
     StartCoroutine(PostSingle(commandId, URL, resultBack));
 }
示例#4
0
 /// <summary>
 /// 一对一请求
 /// </summary>
 /// <param name="commandId">接口名称</param>
 /// <param name="url">请求路径</param>
 /// <param name="resultBack">回调委托</param>
 /// <param name="c">参数</param>
 public void PostOneToOne(string commandId, string url, HttpNetResultDelegate resultBack, params object[] c)
 {
     List<object> args = new List<object>(c);
     SendOneToOne(commandId, args, resultBack, url);
 }
示例#5
0
 /// <summary>
 /// 打包请求
 /// </summary>
 /// <param name="commandId">后端的接口名称</param>
 /// <param name="resultBack">结果委托,报了系统级别错误不会有回调</param>
 /// <param name="c">需要传递的参数</param>
 public void Post(string commandId, HttpNetResultDelegate resultBack, params object[] c)
 {
     List<object> args = new List<object>(c);
     queueDataGroup.AddRequest(commandId, args, resultBack);
     SendRequest();
 }
示例#6
0
 /// <summary>
 /// 移除委托
 /// </summary>
 /// <param name="commandID">根据后端的接口名称注册侦听</param>
 /// <param name="callback">委托回调方法</param>
 public void RemoveResponse(string commandID, HttpNetResultDelegate callback)
 {
     if (onResponseDict.ContainsKey(commandID))
         onResponseDict[commandID] -= callback;
 }
示例#7
0
 /// <summary>
 /// 注册委托,数据请求不管成功还是失败都会触发消息通知
 /// </summary>
 /// <param name="commandID">根据后端的接口名称注册侦听</param>
 /// <param name="callback">委托回调方法</param>
 public void RegisterResponse(string commandID, HttpNetResultDelegate callback)
 {
     if (onResponseDict.ContainsKey(commandID))
         onResponseDict[commandID] += callback;
     else
         onResponseDict[commandID] = callback;
 }