public void AsyncGetRequestByWebClient(string url, IHttpCallback httpCallback) { this.httpCallback = httpCallback; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(url)); request.BeginGetResponse(new AsyncCallback(ReadCallback), request); }
public static IEnumerator GetRequest(string url, object ud, int tag, INetCallback callback, IHttpCallback httpCallback, bool showLoading) { DateTime start = DateTime.Now; HttpPackage hp = new HttpPackage(); hp.w = new WWW(url); hp.Tag = tag; hp.FuncCallback = callback; if (RequestNotify != null && showLoading) { RequestNotify(Net.Status.eStartRequest); } yield return hp.w; if (RequestNotify != null && showLoading) { RequestNotify(Net.Status.eEndRequest); } if(null != httpCallback) { TimeSpan tsStart = new TimeSpan(start.Ticks); TimeSpan tsEnd = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = tsEnd.Subtract(tsStart).Duration(); if(ts.Seconds > OVER_TIME) { hp.overTime = true; } httpCallback.OnHttpRespond(hp, ud); } else { Debug.Log("no http callback"); } }
public static IEnumerator GetRequest(string url, object ud, int tag, INetCallback callback, IHttpCallback httpCallback, bool showLoading) { DateTime start = DateTime.Now; HttpPackage hp = new HttpPackage(); hp.w = new WWW(url); hp.Tag = tag; hp.FuncCallback = callback; if (RequestNotify != null && showLoading) { RequestNotify(Net.Status.eStartRequest); } yield return(hp.w); if (RequestNotify != null && showLoading) { RequestNotify(Net.Status.eEndRequest); } if (null != httpCallback) { TimeSpan tsStart = new TimeSpan(start.Ticks); TimeSpan tsEnd = new TimeSpan(DateTime.Now.Ticks); TimeSpan ts = tsEnd.Subtract(tsStart).Duration(); if (ts.Seconds > OVER_TIME) { hp.overTime = true; } httpCallback.OnHttpRespond(hp, ud); } else { Debug.Log("no http callback"); } }