private IEnumerator ReachabilityTestCoroutine()
        {
            // User data describing whether the app can use carrier data to download asset bundles or not
            // TO-DO: Use proper key for download setting or call boolean property getter in the case we are using a wrapper for this.
            bool downloadViaWifiOnly = ProjectNavigator.Instance ? ProjectNavigator.Instance.DownloadViaWiFiOnly : true;

            // List of all permutations
            // Wifi & 204 => ODR Downloadable
            // Wifi & !204 => No Internet
            // Carrier Data & 204 & Use Data => ODR Downloadable
            // Carrier Data & 204 & Don't Use Data => No Wifi
            // Carrier Data & !204 & Use Data => No Internet
            // Carrier Data & !204 & Don't Use Data => No Wifi
            // Not Reachable & 204 => No Internet
            // Not Reachable & !204 => No Internet

            // If internet is not reachable
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                Debug.Log("ProjectNavigator-> Internet not reachable", DebugContext.SagoApp);
                this.m_Error          = ProjectNavigatorError.OdrErrorNoInternet;
                m_IsInternetReachable = false;
                Complete();
                yield break;
                // If user has access to Wifi or carrier data (ex. 3G, 4G, or LTE)
            }
            else
            {
                // If user only has access to carrier Data and user said not to use carrier data so bypassing 204 test
                if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork && downloadViaWifiOnly)
                {
                    Debug.Log("ProjectNavigator-> There is no access to Wifi", DebugContext.SagoApp);
                    this.m_Error          = ProjectNavigatorError.OdrErrorNoWiFi;
                    m_IsInternetReachable = false;
                    Complete();
                    yield break;
                }

                // We've decided to remove 204 check since any VPNs are blocked in China and
                // this was blocking us from release World in China.

//				// Using web request to see if we actually have access to internet even though Wifi or Carrier Data is available
//				// Ex. Like in the case where a user is at an airport and have Wifi turned on but haven't got access to the internet
//				using (UnityWebRequest www = UnityWebRequest.Get("https://www.google.com/generate_204")) {
//					yield return www.Send();
//					// If 204 test case fails and the app seems to have no access to the internet
//					if (www.responseCode != 204) {
//						Debug.Log("ProjectNavigator-> 204 Test Failed. Internet not reachable.", DebugContext.SagoApp);
//						this.m_Error = ProjectNavigatorError.OdrErrorNoInternet;
//						Complete();
//						m_IsInternetReachable = false;
//						yield break;
//					}
//				}
            }

            m_IsInternetReachable = true;
            Complete();
        }
 public void Dispose()
 {
     if (m_MonoBehaviour != null && m_Coroutine != null)
     {
         m_Error = ProjectNavigatorError.OdrLoadingCancelled;
         m_MonoBehaviour.StopCoroutine(m_Coroutine);
         Complete();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Coroutine implementation for navigating to error scene.
        /// </summary>
        /// <returns>IEnumerator</returns>
        /// <param name="errorType">This is meant for errors that we know of and defined in some form of data like enum types.</param>
        /// <param name="errorMessage">This is a raw string in the case of any errors that we do not know of.</param>
        private IEnumerator NavigateToErrorImpl(ProjectNavigatorError errorType, string errorMessage)
        {
            // Shouldn't call deactivate content here since error is being treated as a medium that
            // sits between project navigation and content navigation, and project navigation logic takes
            // care of this aspect; so if we try to call deactivate content here then any navigation logic
            // that uses content info (in this case, navigating to project) will make the app to crash.

            if (WillNavigateToError != null)
            {
                WillNavigateToError(this.ContentInfo, errorType.ToString(), errorMessage);
            }

            // After we've handled unloading unnecessary resources, we can now navigate to error scene
            SceneNavigator.Instance.NavigateToScene(
                ProjectInfo.Instance.NavigateToErrorScene,
                Instantiate(ProjectInfo.Instance.NavigateToErrorTransition),
                Instantiate(ProjectInfo.Instance.NavigateToErrorTransition),
                null,
                true,
                true
                );

            while (!SceneNavigator.Instance.IsReady)
            {
                yield return(null);
            }

            // apply auto rotation and orientation
            ApplyScreenAutoRotationAndOrientation();

            this.State = ProjectNavigatorState.Error;

            if (DidNavigateToError != null)
            {
                DidNavigateToError(this.ContentInfo, errorType.ToString(), errorMessage);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Call to navigate to error scene.
 /// </summary>
 /// <param name="errorType">This is meant for errors that we know of and defined in some form of data like enum types.</param>
 /// <param name="errorMessage">This is a raw string in the case of any errors that we do not know of.</param>
 public void NavigateToError(ProjectNavigatorError errorType, string errorMessage)
 {
     this.State = ProjectNavigatorState.NavigateToError;
     this.CoroutineHelper.StartCoroutine("NavigateToError", NavigateToErrorImpl(errorType, errorMessage));
 }