private void InitInstallVersion(string fileUrl, byte[] bytes, string errorMessage) { if (bytes == null || bytes.Length == 0) { throw new Exception("local version.dat file is invalid"); } using (ByteBuffer buffer = new ByteBuffer(bytes)) { platform = Singleton <GameEntry> .GetInstance().GetComponent <ResourceComponent>().PlatformName = ValueParse.ReadValue(buffer, ValueParse.StringParse); installVersion = new Version.Version { MasterVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse), MinorVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse), RevisedVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse) }; installZipDecompressFileCount = ValueParse.ReadValue(buffer, ValueParse.IntParse); installZipDecompressSize = ValueParse.ReadValue(buffer, ValueParse.LongParse); Singleton <GameEntry> .GetInstance().GetComponent <ResourceComponent>().AssetBundleVariant = ValueParse.ReadValue(buffer, ValueParse.StringParse); ValueParse.ReadValue(buffer, ValueParse.BoolParse); installZipDecompressPassword = ValueParse.ReadValue(buffer, ValueParse.StringParse); } installVersionIsDone = true; RefreshInstallDataInfo(); }
private void LoadServerVersionCallback(bool isOk, byte[] datas, string errorMessage) { if (isOk && datas != null && datas.Length > 0) { using (ByteBuffer buffer = new ByteBuffer(datas)) { platform = Singleton <GameEntry> .GetInstance().GetComponent <ResourceComponent>().PlatformName = ValueParse.ReadValue(buffer, ValueParse.StringParse); serverVersion = new Version.Version { MasterVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse), MinorVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse), RevisedVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse) }; Singleton <GameEntry> .GetInstance().GetComponent <ResourceComponent>().AssetBundleVariant = ValueParse.ReadValue(buffer, ValueParse.StringParse); serverBundleIsZip = ValueParse.ReadValue(buffer, ValueParse.BoolParse); serverBundleZipPassword = ValueParse.ReadValue(buffer, ValueParse.StringParse); } VersionCompareResult compareResult = Version.Version.CompareResult(serverVersion, currentVersion, false); switch (compareResult) { case VersionCompareResult.Greater: updatePanel.ShowMessageBox(UpdatePanel.enMessageBoxType.YesNo, UpdateStringConfig.UpdateStatusBeginUpdate, UpdateStringConfig.UpdateStringHasFatalErrorNeedReinstall, () => { OpenAppStore(SingletonMono <GameFramework> .GetInstance().GetAppId()); if (Application.isPlaying) { Application.Quit(); } }, () => { if (Application.isPlaying) { Application.Quit(); } }); break; case VersionCompareResult.Equal: case VersionCompareResult.Less: UpdateResource(); break; } } else { //获取服务器的版本信息失败 isUpdateDone = true; updateError("获取服务器的版本信息失败"); } }
private void ClearHotUpdate() { oldFileInfoTable.Clear(); newFileInfoTable.Clear(); downloadList.Clear(); downloadErrorList.Clear(); updateStringConfig = null; updateConfig = null; updateFileCache = null; installVersion = null; firstDecompressVersion = null; currentVersion = null; serverVersion = null; updatePanel.ClearResource(); updatePanel = null; }
/// <summary> /// 加载沙河目录的版本文件 /// </summary> /// <exception cref="Exception"></exception> private void LoadPresistentVersion() { string filePath = PathUtility.GetCombinePath(AppConst.Path.PresistentDataPath, AppConst.AssetBundleConfig.VersionFile); if (FileUtility.IsFileExist(filePath)) { try { using (ByteBuffer buffer = new ByteBuffer(FileUtility.ReadFile(filePath))) { platform = Singleton <GameEntry> .GetInstance().GetComponent <ResourceComponent>().PlatformName = ValueParse.ReadValue(buffer, ValueParse.StringParse); currentVersion = new Version.Version { MasterVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse), MinorVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse), RevisedVersion = ValueParse.ReadValue(buffer, ValueParse.IntParse) }; ValueParse.ReadValue(buffer, ValueParse.IntParse); ValueParse.ReadValue(buffer, ValueParse.LongParse); Singleton <GameEntry> .GetInstance().GetComponent <ResourceComponent>().AssetBundleVariant = ValueParse.ReadValue(buffer, ValueParse.StringParse); ValueParse.ReadValue(buffer, ValueParse.BoolParse); ValueParse.ReadValue(buffer, ValueParse.StringParse); } } catch (Exception e) { throw e; } } else { isUpdateDone = true; updateError("获取获取当前客户端版本信息失败"); } }
/// <summary> /// 获取解压原始zip的应用版本 /// </summary> /// <returns></returns> /// <exception cref="Exception"></exception> private bool GetFirstDecompressVersion() { string path = PathUtility.GetCombinePath(AppConst.Path.PresistentDataPath, AppConst.AssetBundleConfig.IsInstanllDecompressFileName); if (FileUtility.IsFileExist(path)) { try { string text = FileUtility.ReadAllText(path); if (!string.IsNullOrEmpty(text)) { firstDecompressVersion = new Version.Version(text); return(true); } return(false); } catch (Exception e) { throw e; } } return(false); }