コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
            }
        }