public IEnumerator Download() { // 请求游戏版本 string webURL = GameLauncher.GetWebServerURL(); string postContent = GetWebPostContent(); GameLog.Log($"Beginning to request from web : {webURL}"); GameLog.Log($"Post content : {postContent}"); WebPostRequest download = new WebPostRequest(webURL); download.SendRequest(postContent, 30); yield return(download); // Check fatal if (download.HasError()) { download.ReportError(); download.Dispose(); PatchEventDispatcher.SendGameVersionRequestFailedMsg(); yield break; } string responseContent = download.GetResponse(); download.Dispose(); // 解析游戏版本信息 try { GameLog.Log($"Response content : {responseContent}"); WebResponse response = JsonUtility.FromJson <WebResponse>(responseContent); Version gameVersion = new Version(response.GameVersion); int resourceVersion = response.ResourceVersion; bool foundNewApp = response.FoundNewApp; bool forceInstall = response.ForceInstall; string appURL = response.AppURL; PatchUpdater.Instance.GameVersion = gameVersion; PatchUpdater.Instance.ResourceVersion = resourceVersion; if (foundNewApp) { PatchEventDispatcher.SendFoundNewAppMsg(forceInstall, appURL, gameVersion.ToString()); } else { PatchUpdater.Instance.SwitchNext(); } } catch (Exception) { Debug.LogError($"Parse web response failed : {responseContent}"); PatchEventDispatcher.SendGameVersionParseFailedMsg(); } }
private IEnumerator Download() { int updateResourceVersion = PatchUpdater.Instance.ResourceVersion; var operation = PatchManager.Instance.UpdateManifestAsync(updateResourceVersion, 30); yield return(operation); if (operation.Status == EOperationStatus.Succeed) { PatchUpdater.Instance.SwitchNext(); } else { GameLog.Warning(operation.Error); PatchEventDispatcher.SendPatchManifestRequestFailedMsg(); } }
private void CreateDownloader() { PatchUpdater.Instance.CreateAutoDownloader(); var downloader = PatchUpdater.Instance.AutoDownloader; // 如果下载列表为空 if (downloader.TotalDownloadCount == 0) { GameLog.Log("Not found update web files."); PatchUpdater.Instance.Switch(EPatchStates.PatchDone); } else { GameLog.Log($"Found update web files : {downloader.TotalDownloadCount}"); // 发现新更新文件后,挂起流程系统 // 注意:开发者需要在下载前检测磁盘空间不足 int totalDownloadCount = downloader.TotalDownloadCount; long totalDownloadBytes = downloader.TotalDownloadBytes; PatchEventDispatcher.SendFoundUpdateFilesMsg(totalDownloadCount, totalDownloadBytes); } }
void IFsmNode.OnEnter() { PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.PatchDone); }
void IFsmNode.OnEnter() { PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.RequestPatchManifest); MotionEngine.StartCoroutine(Download()); }
void IFsmNode.OnEnter() { PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.CreateDownloader); CreateDownloader(); }
void IFsmNode.OnEnter() { PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.DownloadWebFiles); MotionEngine.StartCoroutine(Download()); }