private void GetDownloadList() { // 获取游戏启动时的下载列表 var downloadList = _patcher.GetAutoPatchDownloadList(); // 如果下载列表为空 if (downloadList.Count == 0) { MotionLog.Log("Not found update web files."); _patcher.Switch(EPatchStates.DownloadOver.ToString()); } else { MotionLog.Log($"Found update web files : {downloadList.Count}"); // 创建补丁下载器 _patcher.CreateInternalDownloader(downloadList); // 发现新更新文件后,挂起流程系统 // 注意:开发者需要在下载前检测磁盘空间不足 int totalDownloadCount = _patcher.InternalDownloader.TotalDownloadCount; long totalDownloadBytes = _patcher.InternalDownloader.TotalDownloadBytes; PatchEventDispatcher.SendFoundUpdateFilesMsg(totalDownloadCount, totalDownloadBytes); } }
public IEnumerator Download() { // 获取最新的游戏版本号 { string url = _patcher.GetWebServerIP(); string post = _patcher.GetWebPostData(); MotionLog.Log($"Beginning to request from web : {url} {post}"); WebPostRequest download = new WebPostRequest(url, post); download.DownLoad(); yield return(download); //Check fatal if (download.HasError()) { download.ReportError(); download.Dispose(); PatchEventDispatcher.SendGameVersionRequestFailedMsg(); yield break; } string response = download.GetResponse(); MotionLog.Log($"Succeed get response from web : {url} {response}"); _patcher.ParseWebResponseData(response); download.Dispose(); } // 检测强更安装包 if (_patcher.ForceInstall) { string requestedGameVersion = _patcher.RequestedGameVersion.ToString(); MotionLog.Log($"Found new APP can be install : {requestedGameVersion}"); PatchEventDispatcher.SendFoundForceInstallAPPMsg(requestedGameVersion, _patcher.AppURL); yield break; } // 检测资源版本是否变化 int newResourceVersion = _patcher.RequestedResourceVersion; int oldResourceVersion = _patcher.LocalResourceVersion; if (newResourceVersion == oldResourceVersion) { MotionLog.Log($"Resource version is not change."); _patcher.Switch(EPatchStates.DownloadOver.ToString()); } else { MotionLog.Log($"Resource version is change : {oldResourceVersion} -> {newResourceVersion}"); _patcher.SwitchNext(); } }
public IEnumerator Download() { // 获取最新的游戏版本号 { string url = _patcher.GetWebServerIP(); string post = _patcher.GetWebPostData(); PatchHelper.Log(ELogLevel.Log, $"Request game version : {url} : {post}"); WebPostRequest download = new WebPostRequest(url, post); yield return(download.DownLoad()); //Check fatal if (download.States != EWebRequestStates.Success) { download.Dispose(); PatchEventDispatcher.SendGameVersionRequestFailedMsg(); yield break; } string responseData = download.GetResponse(); _patcher.ParseResponseData(responseData); download.Dispose(); } int newResourceVersion = _patcher.RequestedResourceVersion; int oldResourceVersion = _patcher.SandboxPatchManifest.Version; // 检测强更安装包 string appInstallURL = _patcher.GetForceInstallAppURL(); if (string.IsNullOrEmpty(appInstallURL) == false) { PatchHelper.Log(ELogLevel.Log, $"Found new APP can be install : {_patcher.GameVersion.ToString()}"); PatchEventDispatcher.SendFoundForceInstallAPPMsg(_patcher.GameVersion.ToString(), appInstallURL); yield break; } // 检测资源版本是否变化 if (newResourceVersion == oldResourceVersion) { PatchHelper.Log(ELogLevel.Log, $"Resource version is not change."); _patcher.Switch(EPatchStates.DownloadOver.ToString()); } else { PatchHelper.Log(ELogLevel.Log, $"Resource version is change : {oldResourceVersion} -> {newResourceVersion}"); _patcher.SwitchNext(); } }
private IEnumerator Download() { // 如果忽略资源版本,那么每次启动都会下载补丁清单 bool ignoreResourceVersion = _patcher.IgnoreResourceVersion; // 新安装的用户首次启动游戏(包括覆盖安装的用户) // 注意:请求的补丁清单会在下载流程结束的时候,自动保存在沙盒里。 bool firstStartGame = PatchHelper.CheckSandboxPatchManifestFileExist() == false; // 检测资源版本是否变化 int newResourceVersion = _patcher.RequestedResourceVersion; int oldResourceVersion = _patcher.LocalResourceVersion; if (ignoreResourceVersion == false && firstStartGame == false && newResourceVersion == oldResourceVersion) { MotionLog.Log($"Resource version is not change."); _patcher.Switch(EPatchStates.PatchDone); } else { // 从远端请求补丁清单 _requestCount++; string url = GetRequestURL(ignoreResourceVersion, newResourceVersion, PatchDefine.PatchManifestFileName); WebGetRequest download = new WebGetRequest(url); download.SendRequest(); yield return(download); // Check fatal if (download.HasError()) { download.ReportError(); download.Dispose(); PatchEventDispatcher.SendPatchManifestRequestFailedMsg(); yield break; } // 解析补丁清单 _patcher.ParseRemotePatchManifest(download.GetText()); download.Dispose(); // 如果发现了新的安装包 if (_patcher.FoundNewApp) { string requestedGameVersion = _patcher.RequestedGameVersion.ToString(); MotionLog.Log($"Found new APP can be install : {requestedGameVersion}"); PatchEventDispatcher.SendFoundNewAppMsg(_patcher.ForceInstall, _patcher.AppURL, requestedGameVersion); } else { if (firstStartGame) { MotionLog.Log("First start game."); } if (newResourceVersion != oldResourceVersion) { MotionLog.Log($"Resource version is change : {oldResourceVersion} -> {newResourceVersion}"); } _patcher.SwitchNext(); } } }