public AssetConfigureParseTask(IAssetConfigureParser parser, byte[] data) : base(true) { parser.ParseAsync(data, assets => { this.Result = assets; this.completed = true; }); }
// IAssetListUpdater public void Check(string updateServerPath, string configureFile, IAssetConfigureParser parser, Action <AssetUpdateType, IAssetDownloader> callback) { this.updateServerPath = updateServerPath; this.configureFile = configureFile; this.callback = callback; if (!Directory.Exists(PathUtility.DataFolder)) { Directory.CreateDirectory(PathUtility.DataFolder); } byte loadType = PERSISTENTDATAPATH; new HttpDownloadTask(this.updateServerPath + configureFile + "?") // Add time out (5s) for request .Start() .Continue(task => { if (null != task.Result) // Check null first since IL2CPP will throw exception if converting null to any type { this.configureData = task.Result as byte[]; return(new AssetConfigureParseTask(parser, this.configureData)); } return(null); }) .Continue(task => { remoteConfigure = _CastToAssetConfigure(task.Result); var filePath = PathUtility.ComposeDataPath(configureFile); return(new FileReadTask(filePath)); }) .Continue(task => { return(null != task.Result ? new AssetConfigureParseTask(parser, task.Result as byte[]) : null); }) .Continue(task => { this.localConfigure = _CastToAssetConfigure(task.Result); var fileUrl = PathUtility.ComposeAppUrl(configureFile); return(new WWWLoadTask(fileUrl, 5.0f)); }) .Continue(task => { if (null != task.Result) // Check null first since IL2CPP will throw exception if converting null to any type { var w = task.Result as WWW; if (null == w.error) { return(new AssetConfigureParseTask(parser, w.bytes)); } } return(null); }) .Continue(task => { var assetConfigure = _CastToAssetConfigure(task.Result); if (null != assetConfigure) { if (null == this.localConfigure) { this.localConfigure = assetConfigure; loadType = STREAMINGASSETS; } else { var innerVersion = new GameBox.Framework.Version(assetConfigure.Version); var outerVersion = new GameBox.Framework.Version(this.localConfigure.Version); if (innerVersion.Compare(outerVersion) > 0) { this.localConfigure = assetConfigure; loadType = STREAMINGASSETS; } } } if (null == this.remoteConfigure) { _NotifyCallback(this.updateType = AssetUpdateType.INVALID, null); } else if (null == this.localConfigure) { _NotifyCallback(this.updateType = AssetUpdateType.HOTUPDATE, _SetupHotUpdateDownloaderWithoutCheck(this.updateServerPath, remoteConfigure)); } else { var localVersion = new GameBox.Framework.Version(this.localConfigure.Version); var remoteVersion = new GameBox.Framework.Version(this.remoteConfigure.Version); if (remoteVersion.Major != localVersion.Major) { // Major version upgrade indicates full app upgrade _NotifyCallback(this.updateType = AssetUpdateType.FULLUPDATE, null); } else if (0 != remoteVersion.Compare(localVersion)) { // Major version is same but minor version is upgrade indicates hot assets upgrade _SetupHotUpdateDownloaderAsync(this.updateServerPath, loadType, this.remoteConfigure, downloader => { _NotifyCallback(this.updateType = (null != downloader ? AssetUpdateType.HOTUPDATE : AssetUpdateType.UPDATED), downloader); }); } else { _NotifyCallback(this.updateType = AssetUpdateType.UPDATED, null); } } return(null); }); }