Пример #1
0
 public static void StartContentUpdate(DynamicContentParam param)
 {
     Debug.Log("StartContentUpdate - Started");
     Assertion.Check(!m_isLoadingInProgress);
     if (m_isLoadingInProgress)
     {
         Debug.Log("StartContentUpdate - Stopping update-in-progress");
         m_isLoadingInProgress = false;
         Instance.StopCoroutine("DoContentUpdate");
     }
     if (m_isCheckingInProgress)
     {
         Debug.Log("StartContentUpdate - Stopping check-in-progress");
         m_isCheckingInProgress = false;
         Instance.StopCoroutine("DoCheckForUpdates");
     }
     Reset(true);
     m_isLoadingInProgress = true;
     Instance.StartCoroutine("DoContentUpdate", param);
     Debug.Log("StartContentUpdate - Finished");
 }
Пример #2
0
/*
 *                      private IEnumerator DoForceUpdateCheck()
 *                      {
 *                              // check for forced updates
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Request");
 *                              ForcedUpdate.Init(UrlsToForcedUpdate[0], BuildTag);
 *                              ForcedUpdate.CheckUpdateStatus();
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Waiting for the result");
 *                              DateTime dateTime = DateTime.Now;
 *                              while(ForcedUpdate.IsCheckInProgress())
 *                              {
 *                                      if((DateTime.Now - dateTime).TotalSeconds > kForcedUpdateTimeOut)
 *                                      {
 *                                              Debug.Log("DoContentUpdate - ForcedUpdate - Timed out");
 *                                              break;
 *                                      }
 *                                      yield return null;
 *                              }
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Got result");
 *                              if(ForcedUpdate.NeedToQuit())
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - NeedToQuit");
 *                                      m_shouldBeUpdated = true;
 *                                      if(OnForcedBinariesUpdate != null)
 *                                      {
 *                                              OnForcedBinariesUpdate();
 *                                      }
 *                                      m_isLoadingInProgress = false;
 *                                      yield break;
 *                              }
 *                              else if(ForcedUpdate.NeedToUpdate())
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - NeedToUpdate");
 *                                      if(OnAvailableBinariesUpdate != null)
 *                                      {
 *                                              if(OnAvailableBinariesUpdate())
 *                                              {
 *                                                      m_shouldBeUpdated = true;
 *                                                      m_isLoadingInProgress = false;
 *                                                      yield break;
 *                                              }
 *                                      }
 *                              }
 *                              else
 *                              {
 *                                      if(OnNoNeedBinariesUpdate != null)
 *                                      {
 *                                              OnNoNeedBinariesUpdate();
 *                                      }
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - UpToDate");
 *                              }
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Finished");
 *                      }
 */
            private IEnumerator DoContentUpdate(DynamicContentParam param)
            {
                Debug.Log("DoContentUpdate - Started");

                // check for forced updates
                #region force update from msk

/*
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Request");
 *                              ForcedUpdate.Init(UrlsToForcedUpdate[0], BuildTag);
 *                              ForcedUpdate.CheckUpdateStatus();
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Waiting for the result");
 *                              DateTime dateTime = DateTime.Now;
 *                              while(ForcedUpdate.IsCheckInProgress())
 *                              {
 *                                      if((DateTime.Now - dateTime).TotalSeconds > kForcedUpdateTimeOut)
 *                                      {
 *                                              Debug.Log("DoContentUpdate - ForcedUpdate - Timed out");
 *                                              break;
 *                                      }
 *                                      yield return null;
 *                              }
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Got result");
 *                              if(ForcedUpdate.NeedToQuit())
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - NeedToQuit");
 *                                      m_shouldBeUpdated = true;
 *                                      if(OnForcedBinariesUpdate != null)
 *                                      {
 *                                              OnForcedBinariesUpdate();
 *                                      }
 *                                      m_isLoadingInProgress = false;
 *                                      yield break;
 *                              }
 *                              else if(ForcedUpdate.NeedToUpdate())
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - NeedToUpdate");
 *                                      if(OnAvailableBinariesUpdate != null)
 *                                      {
 *                                              if(OnAvailableBinariesUpdate())
 *                                              {
 *                                                      m_shouldBeUpdated = true;
 *                                                      m_isLoadingInProgress = false;
 *                                                      yield break;
 *                                              }
 *                                      }
 *                              }
 *                              else
 *                              {
 *                                      Debug.Log("DoContentUpdate - ForcedUpdate - UpToDate");
 *                              }
 *                              Debug.Log("DoContentUpdate - ForcedUpdate - Finished");
 */
                #endregion
                #region ABTesting from msk
                // prepare initial variant data for the resolution

/*
 *                              Debug.Log("DoContentUpdate - ABTesting - Prepare initial variant");
 *                              Dictionary<string, string> initialVariantData = new Dictionary<string, string>();
 *                              initialVariantData.Add(DecisionTable.RESOLUTION_KEY_VARIANT_ID, "DefaultOffline");
 *                              string str = null;
 *                              foreach(string url in UrlsToDefaultAssetBundles)
 *                              {
 *                                      str = (str != null) ? (str + ";" + url) : url;
 *                              }
 *                              initialVariantData.Add("AssetBundlesUrls", str);
 *
 *                              // do A/B testing
 *                              Debug.Log("DoContentUpdate - ABTesting - Request resolution");
 *                              m_resolution = Resolution.Retrieve(initialVariantData, UrlsToABTestingDecisionTable);
 *                              Debug.Log("DoContentUpdate - ABTesting - Waiting for the result");
 *                              while(!m_resolution.Ready)
 *                              {
 *                                      yield return null;
 *                              }
 *                              Debug.Log("DoContentUpdate - ABTesting - Resolved");
 *
 *                              // unload previously loaded asset bundles
 *                              if(m_indexInfo != null && !param.IsAddonContent)
 *                              {
 *                                      Debug.Log("DoContentUpdate - AssetBundles - Unload previously loaded ones");
 *                                      m_indexInfo.UnloadAll(true);
 *                              }
 *
 *                              bool success = false;
 #if !ASSET_BUNDLE_FORCE_ONLINE
 *                              Assertion.Check(m_resolution.Data != null, "DoContentUpdate - Retrieved ABTesting variant data are corrupted");
 #endif
 */
                #endregion

                #region Get Asset bundles list from server
                bool success = false;
//				Debug.Log("Get Asset Bundles list from: "+UrlToDynamicContentInfo);
//				DynamicContentInfo DCInfo = new DynamicContentInfo(UrlToDynamicContentInfo);
//				StartCoroutine(DCInfo.StartDownloadContent());
//				while(!DCInfo.Ready)
//				{
//					yield return null;
//				}
//				Hashtable assetBundleInfo = DCInfo.Result;
                #endregion

//				if((m_resolution.Data != null) && m_resolution.Data.ContainsKey("AssetBundlesUrls"))
                if (param.DCInfoCache != null)
                {
                    // load asset bundles
                    Debug.Log("DoContentUpdate - AssetBundles - Download");
                    //make multi-version files
                    string[] orgVersionFileUrls = param.DCInfoCache.AssetBundleList.ToArray(typeof(string)) as string[];
//					if(param != null && param.ContentType == DynamicContentParam.EnumContentType.CT_SPECIAL_INDEX)
//					{
                    string curVersionFileUrl = param.CheckAllSpecialIndexNameValid(orgVersionFileUrls);
                    Assertion.Check(!string.IsNullOrEmpty(curVersionFileUrl), "DoContentUpdate- Wrong Special Index Name" + param.SpecialIndexName);

//					}
//					else
//					{
//						versionFileUrls = orgVersionFileUrls;
//					}

//					if (versionFileUrls == null)
//					{
//						Debug.LogWarning("No Asset Bundle is need update");
//						success = true;
//					}
//					else
//					{
                    LogEventStarted(curVersionFileUrl);
                    string[] temp = { curVersionFileUrl };
                    m_indexInfo = AssetBundles.DownloadAll(temp);
                    param.TargetIndexDownloadInfo.IndexDownloadInfo = m_indexInfo;
                    m_isIndexInfo = true;
                    Debug.Log("DoContentUpdate - AssetBundles - Waiting for the result");
                    while (m_indexInfo.state == IndexInfo.State.InProgress)
                    {
                        yield return(null);
                    }

                    LogEventEnded(m_indexInfo);
                    Debug.Log(string.Format("DoContentUpdate - AssetBundles - Downloaded with result: {0}, from: {1}", m_indexInfo.state, m_indexInfo.source));
                    switch (m_indexInfo.state)
                    {
                    case IndexInfo.State.Failed:
                        success = false;
                        break;

                    case IndexInfo.State.Succeeded:
                        success = true;
                        break;

                    default:
                        // SANITY CHECK
                        Assertion.Check(false);
                        break;
                    }
                    //}
                }
                else
                {
                    success = false;
                }

//				if(success)
//				{
//					Assertion.Check(CustomDynamicContent != null);
//					if((CustomDynamicContent != null) && (CustomDynamicContent.Count > 0))
//					{
//						// load optional configs
//						Debug.Log("DoContentUpdate - CustomUpdate");
//						foreach(ICustomDynamicContent customDynamicContent in CustomDynamicContent)
//						{
//							customDynamicContent.StartContentUpdate(m_resolution);
//							while(customDynamicContent.IsInProgress)
//							{
//								yield return null;
//							}
//							success &= customDynamicContent.Result;
//						}
//						Debug.Log("DoContentUpdate - CustomUpdate is finished with result: {0}", success);
//					}
//					else
//					{
//						success = true;
//					}
//				}
//
//				if(success)
//				{
//					Debug.Log("DoContentUpdate - ABTesting - Commiting variant");
//					success = m_resolution.Commit();
//				}

                Debug.Log("DoContentUpdate - Overall result is {0}");
                if (success)
                {
                    if (OnSuccess != null)
                    {
                        Debug.Log("DoContentUpdate - OnSuccess");
                        OnSuccess();
                    }
                }
                else
                {
                    if (OnFail != null)
                    {
                        Debug.Log("DoContentUpdate - OnFail");
                        OnFail();
                    }
                }

                // finish
                m_shouldBeUpdated     = false;
                m_isLoadingInProgress = false;
                //m_wasOneLoadAtLeast = true;
                Debug.Log("DoContentUpdate - Finished");
                yield break;
            }
Пример #3
0
 /// <summary>
 /// Starts to update dynamic content.
 /// Use delegates to handle different situations.
 /// </summary>
 public static void StartContentUpdate(DynamicContentParam param = null)
 {
     Debug.Log("StartContentUpdate - Started");
     Impl.StartContentUpdate(param);
     Debug.Log("StartContentUpdate - Finished");
 }