Beispiel #1
0
        internal override void Update()
        {
            if (_steps == ESteps.None || _steps == ESteps.Done)
            {
                return;
            }

            if (_steps == ESteps.LoadWebManifest)
            {
                string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestFileName(_resourceVersion));
                YooLogger.Log($"Beginning to request patch manifest : {webURL}");
                _downloader = new UnityWebDataRequester();
                _downloader.SendRequest(webURL, _timeout);
                _steps = ESteps.CheckWebManifest;
            }

            if (_steps == ESteps.CheckWebManifest)
            {
                Progress = _downloader.Progress();
                if (_downloader.IsDone() == false)
                {
                    return;
                }

                // Check error
                if (_downloader.HasError())
                {
                    _steps = ESteps.Done;
                    Status = EOperationStatus.Failed;
                    Error  = _downloader.GetError();
                }
                else
                {
                    // 解析补丁清单
                    if (ParseRemotePatchManifest(_downloader.GetText()))
                    {
                        _steps = ESteps.Done;
                        Status = EOperationStatus.Succeed;
                    }
                    else
                    {
                        _steps = ESteps.Done;
                        Status = EOperationStatus.Failed;
                        Error  = $"URL : {_downloader.URL} Error : remote patch manifest content is invalid";
                    }
                }
                _downloader.Dispose();
            }
        }
Beispiel #2
0
        internal override void Update()
        {
            if (_steps == ESteps.None || _steps == ESteps.Done)
            {
                return;
            }

            if (_steps == ESteps.LoadStaticVersion)
            {
                string webURL = GetStaticVersionRequestURL(YooAssetSettings.VersionFileName);
                YooLogger.Log($"Beginning to request static version : {webURL}");
                _downloader = new UnityWebDataRequester();
                _downloader.SendRequest(webURL, _timeout);
                _steps = ESteps.CheckStaticVersion;
            }

            if (_steps == ESteps.CheckStaticVersion)
            {
                Progress = _downloader.Progress();
                if (_downloader.IsDone() == false)
                {
                    return;
                }

                if (_downloader.HasError())
                {
                    _steps = ESteps.Done;
                    Status = EOperationStatus.Failed;
                    Error  = _downloader.GetError();
                }
                else
                {
                    if (int.TryParse(_downloader.GetText(), out int value))
                    {
                        ResourceVersion = value;
                        _steps          = ESteps.Done;
                        Status          = EOperationStatus.Succeed;
                    }
                    else
                    {
                        _steps = ESteps.Done;
                        Status = EOperationStatus.Failed;
                        Error  = $"URL : {_downloader.URL} Error : static version content is invalid.";
                    }
                }
                _downloader.Dispose();
            }
        }
Beispiel #3
0
        internal override void Update()
        {
            if (_steps == ESteps.None || _steps == ESteps.Done)
            {
                return;
            }

            if (_steps == ESteps.LoadWebManifestHash)
            {
                string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestHashFileName(_resourceVersion));
                YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
                _downloader1 = new UnityWebDataRequester();
                _downloader1.SendRequest(webURL, _timeout);
                _steps = ESteps.CheckWebManifestHash;
            }

            if (_steps == ESteps.CheckWebManifestHash)
            {
                if (_downloader1.IsDone() == false)
                {
                    return;
                }

                // Check error
                if (_downloader1.HasError())
                {
                    _steps = ESteps.Done;
                    Status = EOperationStatus.Failed;
                    Error  = _downloader1.GetError();
                }
                else
                {
                    string webManifestHash    = _downloader1.GetText();
                    string cachedManifestHash = GetSandboxPatchManifestFileHash(_resourceVersion);

                    // 如果补丁清单文件的哈希值相同
                    if (cachedManifestHash == webManifestHash)
                    {
                        YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
                        LoadSandboxPatchManifest(_resourceVersion);
                        _steps = ESteps.InitVerifyingCache;
                    }
                    else
                    {
                        YooLogger.Log($"Patch manifest hash is change : {webManifestHash} -> {cachedManifestHash}");
                        _steps = ESteps.LoadWebManifest;
                    }
                }
                _downloader1.Dispose();
            }

            if (_steps == ESteps.LoadWebManifest)
            {
                string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestFileName(_resourceVersion));
                YooLogger.Log($"Beginning to request patch manifest : {webURL}");
                _downloader2 = new UnityWebDataRequester();
                _downloader2.SendRequest(webURL, _timeout);
                _steps = ESteps.CheckWebManifest;
            }

            if (_steps == ESteps.CheckWebManifest)
            {
                if (_downloader2.IsDone() == false)
                {
                    return;
                }

                // Check error
                if (_downloader2.HasError())
                {
                    _steps = ESteps.Done;
                    Status = EOperationStatus.Failed;
                    Error  = _downloader2.GetError();
                }
                else
                {
                    // 解析补丁清单
                    if (ParseAndSaveRemotePatchManifest(_resourceVersion, _downloader2.GetText()))
                    {
                        _steps = ESteps.InitVerifyingCache;
                    }
                    else
                    {
                        _steps = ESteps.Done;
                        Status = EOperationStatus.Failed;
                        Error  = $"URL : {_downloader2.URL} Error : remote patch manifest content is invalid";
                    }
                }
                _downloader2.Dispose();
            }

            if (_steps == ESteps.InitVerifyingCache)
            {
                InitVerifyingCache();
                _verifyTime = UnityEngine.Time.realtimeSinceStartup;
                _steps      = ESteps.UpdateVerifyingCache;
            }

            if (_steps == ESteps.UpdateVerifyingCache)
            {
                Progress = GetVerifyProgress();
                if (UpdateVerifyingCache())
                {
                    _steps = ESteps.Done;
                    Status = EOperationStatus.Succeed;
                    float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
                    YooLogger.Log($"Verify result : Success {_verifySuccessCount}, Fail {_verifyFailCount}, Elapsed time {costTime} seconds");
                }
            }
        }
        public void Update()
        {
            if (IsDone())
            {
                return;
            }

            if (_steps == ESteps.LoadStaticVersion)
            {
                YooLogger.Log($"Load application static version.");
                string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettings.VersionFileName);
                string url      = PathHelper.ConvertToWWWPath(filePath);
                _downloader1 = new UnityWebDataRequester();
                _downloader1.SendRequest(url);
                _steps = ESteps.CheckStaticVersion;
            }

            if (_steps == ESteps.CheckStaticVersion)
            {
                if (_downloader1.IsDone() == false)
                {
                    return;
                }

                if (_downloader1.HasError())
                {
                    Error  = _downloader1.GetError();
                    _steps = ESteps.Failed;
                }
                else
                {
                    _staticVersion = int.Parse(_downloader1.GetText());
                    _steps         = ESteps.LoadAppManifest;
                }
                _downloader1.Dispose();
            }

            if (_steps == ESteps.LoadAppManifest)
            {
                YooLogger.Log($"Load application patch manifest.");
                string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.GetPatchManifestFileName(_staticVersion));
                string url      = PathHelper.ConvertToWWWPath(filePath);
                _downloader2 = new UnityWebDataRequester();
                _downloader2.SendRequest(url);
                _steps = ESteps.CheckAppManifest;
            }

            if (_steps == ESteps.CheckAppManifest)
            {
                if (_downloader2.IsDone() == false)
                {
                    return;
                }

                if (_downloader2.HasError())
                {
                    Error  = _downloader2.GetError();
                    _steps = ESteps.Failed;
                }
                else
                {
                    // 解析APP里的补丁清单
                    Result = PatchManifest.Deserialize(_downloader2.GetText());
                    _steps = ESteps.Succeed;
                }
                _downloader2.Dispose();
            }
        }