private AsyncWriteRequest OnBundleDownload(WWW www, XBundleData bundle, string error) { AsyncWriteRequest req = new AsyncWriteRequest(); if (string.IsNullOrEmpty(error)) { byte[] bs = www.bytes; new Thread(delegate { req.Location = this.GetLocalPath(bundle); try { File.WriteAllBytes(req.Location, bs); req.IsDone = true; } catch (Exception ex) { this.OnDownloadFailed(ex.Message, req); } }).Start(); } else { this.OnDownloadFailed(error, req); } return(req); }
internal AsyncWriteRequest Download(string meta, uint size, float percent) { this._meta_awr = new AsyncWriteRequest(); this._meta_awr.Size = size; this._meta_awr.Location = meta; this._meta_awr.Name = meta.Substring(meta.LastIndexOf('/') + 1); this._meta_awr.HasError = false; string name = meta.Substring(meta.LastIndexOf("/") + 1); meta = this.MakeToken(this.HostUrl + XSingleton <XUpdater> .singleton.Platform + meta); this._down_loader.GetMeta(meta, name, new XDownloader.HandleBytesDownload(this.OnMetaDownload), percent); return(this._meta_awr); }
private IEnumerator Download(XBundleData bundle, string url, HandleBundleDownload callback1, HandleFetchBundle callback2) { XSingleton <XTimerMgr> .singleton.KillTimer(this._token); this._token = XSingleton <XTimerMgr> .singleton.SetTimer(0.1f, this._progressCb, null); this._downloader = new WWW(url); yield return(this._downloader); XSingleton <XTimerMgr> .singleton.KillTimer(this._token); this.Progress(null); XSingleton <XTimerMgr> .singleton.KillTimer(this._token); bool flag = false; if (callback1 != null) { AsyncWriteRequest asyncWriteRequest = callback1(this._downloader, bundle, this._downloader.error); while (!asyncWriteRequest.IsDone) { if (asyncWriteRequest.HasError) { flag = true; break; } yield return(null); } XSingleton <XUpdater> .singleton.XPlatform.SetNoBackupFlag(asyncWriteRequest.Location); } if (flag) { this._log.Length = 0; this._log.AppendFormat(XSingleton <XStringTable> .singleton.GetString("XUPDATE_ERROR_DOWNLOADRESFAILED"), bundle.Name); XSingleton <XLoadingUI> .singleton.SetStatus(this._log.ToString(), 255, 255, 255); } else if (callback2 != null) { callback2(this._downloader, this._downloader.bytes, bundle, this._download); } this._downloader = null; yield break; }
private void OnDownloadFailed(string error, AsyncWriteRequest awr) { XSingleton <XDebug> .singleton.AddErrorLog("Download Meta ", awr.Name, " error: ", error, null, null); awr.HasError = true; }