public override void OnSet(object data) { base.OnSet (data); string encrypt = Encrypt.SHA1Key (BuildVersionBindings.GetBuildVersion () + "Hellgate"); // HDebug.Log (encrypt); List<string> param = new List<string> (); param.Add (BASE_URL); param.Add (encrypt); param.Add (Util.GetDevice ()); param.Add ("manifest"); string url = Http.CreateURL (param, "json"); HttpData hD = new HttpData (url); hD.popUp = false; hD.finishedDelegate = CallbackManifest; HttpManager.Instance.GET (hD); progress.SetActive (false); percent.SetActive (false); count.SetActive (false); goMainFlag = false; SetLabelTextValue (status, "Checking maifest"); }
/// <summary> /// Initializes a new instance of the <see cref="Hellgate.AssetBundleInitalDownloader"/> class. /// Examples url : https://dl.dropboxusercontent.com/u/95277951/hellgate/fd3caab6ae1a959fd769a2a3ed9344e5adc98402/pc/resource.json /// </summary> /// <param name="baseUrl">Base URL.</param> /// <param name="name">Name.</param> /// <param name="assetExtension">Asset extension.</param> public AssetBundleInitialDownloader(string url, string baseUrl = "", string assetExtension = "unity3d") { AssetBundleData.BASE_URL = baseUrl; AssetBundleData.EXTENSION = assetExtension; assetBundleManager = AssetBundleManager.Instance; httpManager = HttpManager.Instance; httpData = new HttpData (url); httpData.popUp = false; httpData.finishedDelegate = Callback; }
public void GetTexture(HttpData data, Http.FinishedDelegate finish = null) { data.method = Http.kHttpVerbTexture; Request(data, finish); }
/// <summary> /// Request the specified data and post. /// </summary> /// <param name="data">HttpData.</param> /// <param name="post">If set to <c>true</c> post.</param> public void Request(HttpData data, Http.FinishedDelegate finish = null) { time = Time.time; Action innerRequest = () => { if (preReuqest != null) { data = preReuqest(data); } this.data = data; Http http; #if UNITY_5_4_OR_NEWER if (data.method == UnityWebRequest.kHttpVerbPOST) { #else if (data.post) { #endif http = new Http(this, data.url); http.AddRangeData(data.datas); } else { http = new Http(this, data.url, data.datas); } #if UNITY_5_4_OR_NEWER http.method = data.method; http.audioType = data.audioType; http.OnFail = (UnityWebRequest www) => { this.www = www; OnFail(); }; http.OnDisposed = (UnityWebRequest www) => { this.www = www; OnDisposed(); }; http.OnDone = (UnityWebRequest www) => { this.www = www; OnDone(); }; #else http.OnFail = (WWW www) => { this.www = www; OnFail(); }; http.OnDisposed = (WWW www) => { this.www = www; OnDisposed(); }; http.OnDone = (WWW www) => { this.www = www; OnDone(); }; #endif // set headers http.Headers = data.headers; // set timeout time http.Timeout = data.timeout; http.Request(); }; if (finish != null) { data.finishedDelegate = finish; } if (data.popUp) { if (SceneManager.Instance.DefaultLoadingJobSceneName != "") { if (SceneManager.Instance.IsLoadingJob) { HDebug.LogWarning("Now loading scene active"); } SceneManager.Instance.PopUp(SceneManager.Instance.DefaultLoadingJobSceneName, null, delegate(SSceneController ctrl) { popUp = ctrl; innerRequest(); }); } else { HDebug.LogWarning("The default loading scene is not set"); } } else { innerRequest(); } }
/// <summary> /// POST request the specified data. /// </summary> /// <param name="data">HttpData.</param> public void POST (HttpData data) { data.post = true; Request (data); }
/// <summary> /// GET request the specified data. /// </summary> /// <param name="data">HttpData.</param> public void GET (HttpData data) { Request (data); }
/// <summary> /// Request the specified data. /// </summary> /// <param name="data">HttpData.</param> public void Request (HttpData data) { Request (data, data.post); }
/// <summary> /// Request the specified data and post. /// </summary> /// <param name="data">HttpData.</param> /// <param name="post">If set to <c>true</c> post.</param> public void Request (HttpData data, bool post) { time = Time.time; Action innerRequest = () => { if (preReuqest != null) { data = preReuqest (data); } Http http; if (post) { // post reuqest http = new Http (this, data.url); http.Headers = data.headers; foreach (KeyValuePair<string, string> kVP in data.datas) { http.AddData (kVP.Key, kVP.Value); } } else { // get request http = new Http (this, data.url, data.datas); } // Set timeout time. http.Timeout = data.timeout; http.OnFail = (WWW www) => { OnFail (data, www); }; http.OnDisposed = (WWW www) => { OnDisposed (data, www); }; http.OnDone = (WWW www) => { OnDone (data, www); }; http.Request (); }; if (data.popUp) { if (SceneManager.Instance.DefaultLoadingJobSceneName != "") { if (SceneManager.Instance.IsLoadingJob) { HDebug.LogWarning ("Now loading scene active"); } SceneManager.Instance.PopUp (SceneManager.Instance.DefaultLoadingJobSceneName, null, delegate(SSceneController ctrl) { popUp = ctrl; innerRequest (); }); } else { HDebug.LogWarning ("The default loading scene is not set"); } } else { innerRequest (); } }
/// <summary> /// Raises the done event. /// </summary> /// <param name="data">Data.</param> /// <param name="www">Www.</param> protected virtual void OnDone (HttpData data, WWW www) { Log (data, www); CallbackRequest (data, www); }
/// <summary> /// Callbacks the request. /// </summary> /// <param name="data">Data.</param> /// <param name="www">Www.</param> protected virtual void CallbackRequest (HttpData data, WWW www) { Action innerCallback = () => { popUp = null; if (response != null) { if (!response (www)) { return; } } if (data.finishedDelegate != null) { data.finishedDelegate (www); } }; if (popUp != null) { SceneManager.Instance.Close (delegate { innerCallback (); }); } else { innerCallback (); } }
/// <summary> /// Debug the specified data and www. /// warring is timeover /// </summary> /// <param name="data">Data.</param> /// <param name="www">Www.</param> protected void Log (HttpData data, WWW www) { time = Time.time - time; if (!debug) { return; } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder (); stringBuilder.AppendFormat ("[Request time] {0}\n[WWW.url] {1}\n", time, data.url); if (data.headers != null) { stringBuilder.Append ("[WWWForm.headers]\n"); foreach (KeyValuePair<string, string> pair in data.headers) { stringBuilder.AppendFormat ("{0} : {1}\n", pair.Key, pair.Value); } stringBuilder.Append ("\n"); } if (data.headers != null) { stringBuilder.Append ("[WWWForm.data]\n"); foreach (KeyValuePair<string, string> pair in data.datas) { stringBuilder.AppendFormat ("{0} : {1}\n", pair.Key, pair.Value); } stringBuilder.Append ("\n"); } if (www == null) { HDebug.LogWarning (stringBuilder.ToString ()); } else if (www.error != null) { stringBuilder.AppendFormat ("[WWW.error]\n{0}\n", www.error); HDebug.LogError (stringBuilder.ToString ()); } else { HDebug.Log (stringBuilder.ToString ()); } }
public void OnClickRequest() { HttpData http = new HttpData ("test", "json"); http.finishedDelegate = delegate (WWW www) { if (www == null) { // time over } else if (www.error != null) { // error } else { HellgateHttpDataEx data = JsonUtil.FromJson<HellgateHttpDataEx> (www.text); url = data.Url; button.SetActive (true); } }; HttpManager.Instance.GET (http); }