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 loadContentManifest()
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();
            yield return(manifestDirectory_download());

            timer.Stop();
            if (manifestDirectory == null)
            {
                Log.LogError(this, "The ContentManifestDirectory downloaded is null! The request to download the directory either was not made or failed to download and deserialize. Reverting to the embedded ContentManifest as no ContentManifestDirectoryEntry is available to reference.");
                handleFailure();
                yield break;
            }
            embeddedManifest = manifestService.LoadEmbeddedManifest();
            DateTimeOffset contentDate      = manifestService.GetContentDate();
            Version        clientVersion    = ClientInfo.ParseClientVersion(ClientInfo.Instance.ClientVersion);
            Version        clientApiVersion = ClientInfo.ParseClientVersion(manifestService.GetClientApiVersionStr());
            string         platform         = manifestService.GetClientPlatform();
            string         environment      = manifestService.GetServerEnvironment().ToString().ToLower();
            ContentManifestDirectoryEntry clientDirectoryEntry = manifestDirectory.FindEntry(contentDate, clientVersion, platform, environment);

            appUpgradeAvailable = manifestDirectory.DoesNewerVersionExist(contentDate, clientVersion, platform, environment);
            if (clientDirectoryEntry == null)
            {
                Log.LogErrorFormatted(this, "No client directory entry available for clientVersion={0}, platform={1}, environment={2}. \nTriggering force upgrade.", clientVersion.ToString(), platform, environment);
                handleFailure(requiresAppUgrade: true);
                yield break;
            }
            ContentManifestDirectoryEntry contentDirectoryEntry = clientDirectoryEntry;

            if (!clientVersion.Equals(clientApiVersion))
            {
                contentDirectoryEntry = manifestDirectory.FindEntry(contentDate, clientApiVersion, platform, environment);
                if (contentDirectoryEntry == null)
                {
                    Log.LogErrorFormatted(this, "Missing Client API Version: No content available for clientApiVersion={0}, platform={1}, environment={2}. Falling back to embedded content version", clientApiVersion.ToString(), platform, environment);
                    handleFailure();
                    yield break;
                }
            }
            if (contentDirectoryEntry.IsEmbeddedContent())
            {
                contentManifest = embeddedManifest;
                checkContentVersionAndManifestHashInManifest(contentManifest, contentDirectoryEntry);
            }
            else
            {
                yield return(contentManifest_download(contentDirectoryEntry));

                contentManifest = ContentManifestUtility.Merge(embeddedManifest, downloadedManifest);
            }
            onInitializeComplete(contentManifest);
        }
Ejemplo n.º 3
0
 public string GetReleaseNameFromEntry(ContentManifestDirectoryEntry entry)
 {
     if (entry != null && entry.content != EMBEDDED_CONTENT && entry.content != null)
     {
         if (entry.content.IndexOf('_') > 0)
         {
             return(entry.content.Split('_')[0]);
         }
         return(entry.content);
     }
     return(string.Empty);
 }
Ejemplo n.º 4
0
 public ContentManifestDirectoryEntry FindEmbeddedEntry(DateTimeOffset targetDate, string clientVersion, string clientPlatform)
 {
     for (int i = 0; i < directory.Length; i++)
     {
         ContentManifestDirectoryEntry contentManifestDirectoryEntry = directory[i];
         if (contentManifestDirectoryEntry.content == EMBEDDED_CONTENT)
         {
             return(contentManifestDirectoryEntry);
         }
     }
     Debug.LogError("FindEmbeddedEntry(): NO Embedded ContentManifestDirectoryEntry Found!");
     return(null);
 }
Ejemplo n.º 5
0
        public ContentManifestDirectoryEntry FindEntry_Prod(string client_version, string client_platform)
        {
            string environment = Disney.Kelowna.Common.Environment.Environment.PRODUCTION.ToString().ToLower();

            for (int i = 0; i < directory.Length; i++)
            {
                ContentManifestDirectoryEntry contentManifestDirectoryEntry = directory[i];
                if (contentManifestDirectoryEntry.IsEqualTo(client_version, client_platform, environment))
                {
                    return(contentManifestDirectoryEntry);
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
        private ContentManifest contentManifest_loadEmbedded()
        {
            ContentManifestDirectory      contentManifestDirectory      = manifestDirectory_loadEmbedded();
            ContentManifestDirectoryEntry contentManifestDirectoryEntry = contentManifestDirectory.FindEmbeddedEntry(contentDate, clientApiVersionStr, clientPlatform);

            if (contentManifestDirectoryEntry == null)
            {
                object[]       array          = new object[3];
                DateTimeOffset dateTimeOffset = contentDate;
                array[0] = dateTimeOffset.ToString();
                array[1] = clientApiVersionStr;
                array[2] = clientPlatform;
                Log.LogErrorFormatted(this, "contentManifest_loadEmbedded(): unable to FindEmbeddedEntry for {0}, {1}, {2}", array);
            }
            return(new ContentManifest(Resources.Load <TextAsset>(contentManifestDirectoryEntry.url)));
        }
Ejemplo n.º 7
0
        public List <string> GetReleaseNamesUpToAndIncludingDate(DateTimeOffset date, string client_version, string client_platform, string environment)
        {
            List <string> list = new List <string>();

            if (directory == null || directory.Length <= 0)
            {
                return(list);
            }
            for (int i = 0; i < directory.Length; i++)
            {
                ContentManifestDirectoryEntry contentManifestDirectoryEntry = directory[i];
                if (contentManifestDirectoryEntry.IsEqualTo(client_version, client_platform, environment) && getReleaseDateFromEntry(contentManifestDirectoryEntry) <= date)
                {
                    list.Add(GetReleaseNameFromEntry(contentManifestDirectoryEntry));
                }
            }
            return(list);
        }
Ejemplo n.º 8
0
 private DateTimeOffset getReleaseDateFromEntry(ContentManifestDirectoryEntry entry)
 {
     if (entry.content == EMBEDDED_CONTENT)
     {
         return(DateTimeOffset.MinValue);
     }
     if (!string.IsNullOrEmpty(entry.releaseDate))
     {
         return(CommonDateTime.Deserialize(entry.releaseDate));
     }
     string[] array = entry.content.Split('_');
     if (array.Length == 2)
     {
         string dateString = array[1];
         return(CommonDateTime.CreateDate(dateString));
     }
     return(DateTimeOffset.MinValue);
 }
Ejemplo n.º 9
0
 public bool DoesNewerVersionExist(DateTimeOffset targetDate, Version currentVersion, string clientPlatform, string environment)
 {
     for (int i = 0; i < directory.Length; i++)
     {
         ContentManifestDirectoryEntry contentManifestDirectoryEntry = directory[i];
         if (!contentManifestDirectoryEntry.IsEqualTo(clientPlatform, environment))
         {
             continue;
         }
         Version version = ClientInfo.ParseClientVersion(contentManifestDirectoryEntry.client);
         if (version > currentVersion)
         {
             DateTimeOffset releaseDateFromEntry = getReleaseDateFromEntry(contentManifestDirectoryEntry);
             if (releaseDateFromEntry <= targetDate)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 private void checkContentVersionAndManifestHashInManifest(ContentManifest manifest, ContentManifestDirectoryEntry directoryEntry)
 {
     if (manifest == null || directoryEntry == null)
     {
         Log.LogErrorFormatted(this, "Can't check on manifest since one of the parameters is null manifest={0}, directoryEntry={1}\t", manifest, directoryEntry);
         return;
     }
     if (string.IsNullOrEmpty(manifest.ContentManifestHash) && !string.IsNullOrEmpty(directoryEntry.url))
     {
         string text = (manifest.ContentManifestHash = Path.GetFileNameWithoutExtension(directoryEntry.url));
     }
     if (string.IsNullOrEmpty(manifest.ContentVersion))
     {
         manifest.ContentVersion = directoryEntry.contentVersion;
     }
     else if (manifest.ContentVersion != directoryEntry.contentVersion)
     {
         manifest.ContentVersion = directoryEntry.contentVersion;
     }
 }