コード例 #1
0
ファイル: VersionMgr.cs プロジェクト: qweewqpkn/MyStudy
        private void SaveLocalVersionCode()
        {
            ResponseVersionManifestData data = new ResponseVersionManifestData();

            data.version = _localVerCode.Version;
            string localVerFilePath = FileUtils.LocalResRootPath + HotUpdateDefs.kPackageVersionFile;

            File.WriteAllText(localVerFilePath, JsonUtility.ToJson(data));
        }
コード例 #2
0
ファイル: VersionMgr.cs プロジェクト: qweewqpkn/MyStudy
        public IEnumerator RequestRemoteVersionCode(string versionManifestUrl, Action <string> failedCallback, Action <ResponseVersionManifestData> finishCallback)
        {
            // 请求远程最新版本信息
            if (versionManifestUrl.Contains("?"))
            {
                versionManifestUrl += "&__cdn_asset_version__=" + (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))).TotalSeconds;
            }
            else
            {
                versionManifestUrl += "?__cdn_asset_version__=" + (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))).TotalSeconds;
            }
            WWW www = new WWW(versionManifestUrl);

            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                CLogger.LogError("VersionMgr::RequestRemoteVersionCode() - request remote_version.manifest error: " + www.error);
                if (failedCallback != null)
                {
                    CLogger.Log("VersionMgr::RequestRemoteVersionCode() - Request version.manifest failed. Please try again!");
                    failedCallback(www.error);
                }
                www.Dispose();
                yield break;
            }
            // 解析远程最新版本信息
            ResponseVersionManifestData manifestData = null;
            string remoteVersion = string.Empty;

            try
            {
                manifestData  = JsonUtility.FromJson <ResponseVersionManifestData>(www.text);
                remoteVersion = manifestData.version;
            }catch (Exception e)
            {
                CLogger.LogError("VersionMgr::RequestRemoteVersionCode() - parse version.manifest exception: " + e.Message);
                if (failedCallback != null)
                {
                    CLogger.Log("VersionMgr::RequestRemoteVersionCode() - Request version.manifest failed. Please try again!");
                    failedCallback(e.Message);
                }
                www.Dispose();
                yield break;
            }

            manifestData = manifestData != null ? manifestData : new ResponseVersionManifestData();
            CLogger.Log("VersionMgr::RequestRemoteVersionCode() - RequestRemoteVersionCode: " + remoteVersion);
            www.Dispose();
            www = null;

            if (finishCallback != null)
            {
                finishCallback(manifestData);
            }
        }
コード例 #3
0
ファイル: GameUpdateHelper.cs プロジェクト: qweewqpkn/MyStudy
        /// <summary>
        /// 请求服务器Version.manifest文件成功回调
        /// </summary>
        private void OnRequestRemoteVersionSuccess(ResponseVersionManifestData manifestData)
        {
            var handler = handlerMap[HotUpdateEventType.RequestRemoteVersionSuccess];

            if (handler != null)
            {
                string remoteVersion = manifestData.version;
                int    zoneId        = manifestData.zoneId;
                bool   review        = manifestData.review;
                string loginUrl      = manifestData.loginUrl;
                int    force         = manifestData.force;
                handler.Call(remoteVersion, zoneId, review, loginUrl, force);
            }
        }