private IEnumerator get() { ICPipeManifestService cpipeManifestService = Service.Get <ICPipeManifestService>(); CPipeManifestResponse cpipeManifestResponse = new CPipeManifestResponse(); yield return(cpipeManifestService.LookupAssetUrl(cpipeManifestResponse, contentPath)); if (string.IsNullOrEmpty(cpipeManifestResponse.FullAssetUrl)) { Log.LogErrorFormatted(this, "ERROR: CdnGet - contentPath '{0}' NOT FOUND!", contentPath); yield break; } switch (mode) { case ModeEnum.GetString: yield return(getString(cpipeManifestResponse.FullAssetUrl)); break; case ModeEnum.GetFile: yield return(getFile(cpipeManifestResponse.FullAssetUrl)); break; } }
private IEnumerator contentManifest_download(ContentManifestDirectoryEntry directoryEntry) { if (directoryEntry == null) { handleFailure(); yield break; } if (string.IsNullOrEmpty(directoryEntry.url)) { handleFailure(); yield break; } string contentManifestUrl = directoryEntry.url; ICPipeManifestService cpipeManifestService = Service.Get <ICPipeManifestService>(); CPipeManifestResponse cpipeManifestResponse = new CPipeManifestResponse(); yield return(cpipeManifestService.LookupAssetUrl(cpipeManifestResponse, contentManifestUrl)); UnityWebRequest www = UnityWebRequest.GetAssetBundle(cpipeManifestResponse.FullAssetUrl, 1u, 0u); Service.Get <LoadingController>().RegisterDownload(www); yield return(www.SendWebRequest()); Service.Get <LoadingController>().UnRegisterDownload(www); AssetBundle contentBundle = ((DownloadHandlerAssetBundle)www.downloadHandler).assetBundle; if (www.isNetworkError || contentBundle == null) { Log.LogErrorFormatted(this, "Failed to download content bundle from CDN: {0}", www.error); handleFailure(); yield break; } downloadedManifest = ContentHelper.GetContentManifestFromAssetBundle(contentBundle); if (downloadedManifest != null) { checkContentVersionAndManifestHashInManifest(downloadedManifest, directoryEntry); contentManifest_cacheDownloadedToDisk(downloadedManifest); } string[] assetNames = contentBundle.GetAllAssetNames(); for (int i = 0; i < assetNames.Length; i++) { string fileName = Path.GetFileName(assetNames[i]); if (string.Equals(fileName, "ScenesPrereqBundlesManifest.json", StringComparison.OrdinalIgnoreCase)) { TextAsset textAsset = contentBundle.LoadAsset <TextAsset>(assetNames[i]); scenePrereqBundlesManifest = Service.Get <JsonService>().Deserialize <ScenePrereqContentBundlesManifest>(textAsset.text); scenePrereqBundlesManifest_cacheDownloadedToDisk(scenePrereqBundlesManifest); } } contentBundle.Unload(unloadAllLoadedObjects: false); if (downloadedManifest == null) { Log.LogError(this, "Content manifest not found in downloaded bundle! Reverting to the embedded manifest"); handleFailure(); } }
public IEnumerator manifestDirectory_download() { ICPipeManifestService cpipeManifestService = Service.Get <ICPipeManifestService>(); CPipeManifestResponse cpipeManifestResponse = new CPipeManifestResponse(); yield return(cpipeManifestService.LookupAssetUrl(cpipeManifestResponse, "ClientManifestDirectory.json")); bool forceDownload = false; Uri uri = new Uri(cpipeManifestResponse.FullAssetUrl); string manifestDirectory_cachedPath = PathUtil.Combine(Application.persistentDataPath, uri.LocalPath); if (!forceDownload && File.Exists(manifestDirectory_cachedPath)) { string stringToDeserialize = File.ReadAllText(manifestDirectory_cachedPath); manifestDirectory = Service.Get <JsonService>().Deserialize <ContentManifestDirectory>(stringToDeserialize); yield break; } UnityWebRequest www = UnityWebRequest.Get(cpipeManifestResponse.FullAssetUrl); Service.Get <LoadingController>().RegisterDownload(www); yield return(www.SendWebRequest()); Service.Get <LoadingController>().UnRegisterDownload(www); try { if (www.isNetworkError || string.IsNullOrEmpty(www.downloadHandler.text)) { throw new Exception("Failed to download manifest directory from CDN. Reverting to the embedded directory."); } manifestDirectory = Service.Get <JsonService>().Deserialize <ContentManifestDirectory>(www.downloadHandler.text); string parentPath = PathUtil.GetParentPath(manifestDirectory_cachedPath); if (!Directory.Exists(parentPath)) { Directory.CreateDirectory(parentPath); } File.WriteAllText(manifestDirectory_cachedPath, www.downloadHandler.text); } catch (Exception) { manifestDirectory = manifestDirectory_loadEmbedded(); onInitializeComplete(manifestService.LoadEmbeddedManifest()); } }
public WwwBundleDevice(DeviceManager deviceManager, IGcsAccessTokenService gcsAccessTokenService, ICPipeManifestService cpipeManifestService) : base(deviceManager) { this.gcsAccessTokenService = gcsAccessTokenService; this.cpipeManifestService = cpipeManifestService; }