private void LoadABInfo_FromWWW() { string accessPath = DataMng.Instance().RespDataCM_ABVersion.assetBundleVersionList[0].accessPath; WWWHelper wwwhelper = new WWWHelper(accessPath, null, null, 40f); base.StartCoroutine(wwwhelper.StartRequest(new Action <string, string, WWWHelper.TimeOut>(this.OnReceivedAssetBundleInfo))); }
private IEnumerator LoadABData_FromWWW() { string strROOT = AssetBundleMng.Instance().GetAssetBundleRootPath(); string fullpath = string.Empty; for (int i = 0; i < this.abFolderList.Count; i++) { fullpath = string.Concat(new object[] { strROOT, this.abFolderList[i], "?", AssetDataMng.assetVersion }); bool downloadStart = true; while (downloadStart) { this.www_err_bk = string.Empty; WWWHelper www = new WWWHelper(fullpath, null, null, 40f); yield return(base.StartCoroutine(www.StartRequest(new Action <string, string, WWWHelper.TimeOut>(this.OnReceivedAssetBundleData)))); if (string.IsNullOrEmpty(this.www_err_bk)) { downloadStart = false; } else { bool bClosed = false; this.OpenAlert(delegate { bClosed = true; }); while (!bClosed) { yield return(null); } } } } int assetBundleCategoryCount = (this.abidList != null) ? this.abidList.Count : 0; if (this.actCallBack_AB_Init != null) { this.actCallBack_AB_Init(assetBundleCategoryCount); } yield break; }
private IEnumerator WWWRequest(string url, string method, WebAPI.DisableVersionCheckCode disableVersionCheck, string json, WWWResponse response) { Dictionary <string, object> parameters = new Dictionary <string, object>(); Dictionary <string, string> headers = new Dictionary <string, string>(); WWWForm form = new WWWForm(); int code = (int)disableVersionCheck; if (string.IsNullOrEmpty(this.masterDataVersion)) { code = 1; } else { parameters["dataVersion"] = this.masterDataVersion; form.AddField("dataVersion", this.masterDataVersion); } parameters["activityList"] = json; parameters["disabledVC"] = code.ToString(); parameters["appVersion"] = WebAPIPlatformValue.GetAppVersion(); parameters["assetVersion"] = AssetDataMng.assetVersion.ToString(); headers = NpOAuth.Instance.RequestHeaderDic(method, url, parameters); headers["X-AppVer"] = WebAPIPlatformValue.GetAppVersion(); headers["x-puid"] = PlatformUserID.GetId(); form.AddField("activityList", json); form.AddField("disabledVC", code); form.AddField("appVersion", WebAPIPlatformValue.GetAppVersion()); form.AddField("assetVersion", AssetDataMng.assetVersion.ToString()); WWWHelper www = new WWWHelper(url, form.data, headers, this.timeout); IEnumerator request = www.StartRequest(delegate(string responseText, string errorText, WWWHelper.TimeOut isTimeout) { response.responseJson = responseText; response.errorText = errorText; response.errorStatus = ((isTimeout != WWWHelper.TimeOut.YES) ? ((!string.IsNullOrEmpty(errorText)) ? WWWResponse.LocalErrorStatus.LOCAL_ERROR_WWW : WWWResponse.LocalErrorStatus.NONE) : WWWResponse.LocalErrorStatus.LOCAL_ERROR_TIMEOUT); }); yield return(base.StartCoroutine(request)); yield break; }
private Coroutine LoadWWWHelper(string path, TextureManager.SaveData.CacheInfo cacheInfo, Action <Texture2D> callback, float timeoutSeconds, bool isCache) { WWWHelper wwwhelper = new WWWHelper(path, null, null, timeoutSeconds); return(base.StartCoroutine(wwwhelper.StartRequest(delegate(Texture2D loadTex, string errorString, WWWHelper.TimeOut isTimeout) { if (!string.IsNullOrEmpty(errorString)) { global::Debug.Log(errorString); if (callback != null) { callback(null); } return; } if (isTimeout == WWWHelper.TimeOut.YES) { global::Debug.Log("www time out\nURL : " + path); if (callback != null) { callback(null); } return; } if (loadTex != null && isCache) { string jsonText = Convert.ToBase64String(loadTex.EncodeToPNG()); this.StartCoroutine(this.persistentFile.Write(cacheInfo.path, jsonText, delegate(bool isSuccess) { })); bool flag = true; bool flag2 = false; foreach (TextureManager.SaveData.CacheInfo cacheInfo2 in this.saveData.cacheInfoList) { if (cacheInfo2.path == cacheInfo.path) { flag = false; if (cacheInfo2.version < cacheInfo.version) { cacheInfo2.version = cacheInfo.version; flag2 = true; } break; } } if (flag) { this.saveData.cacheInfoList.Add(cacheInfo); flag2 = true; } if (flag2) { while (this.saveData.cacheInfoList.Count > ConstValue.CACHE_TEXTURE_COUNT) { this.Delete(this.saveData.cacheInfoList[0].path); this.saveData.cacheInfoList.RemoveAt(0); } string jsonText2 = JsonMapper.ToJson(this.saveData); this.StartCoroutine(this.persistentFile.Write(this.cachePath, jsonText2, null)); } } if (callback != null) { callback(loadTex); } }))); }