Ejemplo n.º 1
0
        private Autoya(string basePath = "")
        {
            // Debug.LogWarning("autoya initialize start. basePath:" + basePath);

            var isPlayer = false;

            if (Application.isPlaying)
            {
                isPlayer = true;

                // create game object for Autoya.
                var go = GameObject.Find("AutoyaMainthreadDispatcher");
                if (go == null)
                {
                    go = new GameObject("AutoyaMainthreadDispatcher");
                    this.mainthreadDispatcher = go.AddComponent <AutoyaMainThreadDispatcher>();
                    GameObject.DontDestroyOnLoad(go);
                }
                else
                {
                    this.mainthreadDispatcher = go.GetComponent <AutoyaMainThreadDispatcher>();
                }
            }
            else
            {
                // create editor runnner for Autoya.
                this.mainthreadDispatcher = new EditorUpdator();
            }

            _autoyaFilePersistence = new FilePersistence(basePath);

            _autoyaHttp = new HTTPConnection();

            InitializeAssetBundleFeature();

            InitializeAppManifest();

            var isFirstBoot = IsFirstBoot();

            /*
             *  start authentication.
             */
            Authenticate(
                isFirstBoot,
                () => {
                /*
                 *  initialize purchase feature.
                 */
                if (isPlayer)
                {
                    ReloadPurchasability();
                }
            }
                );
        }
            public AuthRouter(ICoroutineUpdater mainthreadDispatcher, Action onBootSucceeded, Action <int, string> onBootFailed, Action onRefreshSucceeded, Action <int, string> onRefreshFailed, bool isFirstBoot)
            {
                this.mainthreadDispatcher = mainthreadDispatcher;

                // set boot handler.
                this.onBootSucceeded = onBootSucceeded;
                this.onBootFailed    = onBootFailed;

                // set refreshToken handler.
                this.onRefreshSucceeded = onRefreshSucceeded;
                this.onRefreshFailed    = onRefreshFailed;

                if (!isFirstBoot)
                {
                    authState = AuthState.Logon;
                    onBootSucceeded();
                    return;
                }

                // start first boot.
                authState = AuthState.Booting;
                mainthreadDispatcher.Commit(FirstBoot());
            }
Ejemplo n.º 3
0
        private Autoya(string basePath = "")
        {
            // Debug.LogWarning("autoya initialize start. basePath:" + basePath);

            var isPlayer = false;

            if (Application.isPlaying)
            {
                isPlayer = true;

                // create game object for Autoya.
                var go = GameObject.Find("AutoyaMainthreadDispatcher");
                if (go == null)
                {
                    go = new GameObject("AutoyaMainthreadDispatcher");
                    this.mainthreadDispatcher = go.AddComponent <AutoyaMainthreadDispatcher>();
                    GameObject.DontDestroyOnLoad(go);
                }
                else
                {
                    this.mainthreadDispatcher = go.GetComponent <AutoyaMainthreadDispatcher>();
                }
            }
            else
            {
                // create editor runnner for Autoya.
                this.mainthreadDispatcher = new EditorUpdator();
            }

            _autoyaFilePersistence = new FilePersistence(basePath);
            _notification          = new Notifications(AutoyaMainthreadDispatcher.AddNativeObserver);
            _autoyaHttp            = new HTTPConnection();

            InitializeAppManifest();

            // setup response handling.
            this.httpResponseHandlingDelegate = HttpResponseHandling;

            /*
             *  endPoint -> AB -> OnBootLoop -> authentication.
             */
            IEnumerator bootSequence()
            {
                // EndPointSelector initialize and update.
                {
                    InitializeEndPointImplementation();

retryEndPointRequest:
                    var failed = false;
                    var cor  = UpdateEndPoints(() => failed = true);
                    var cont = cor.MoveNext();
                    if (cont)
                    {
                        yield return(null);

                        while (cor.MoveNext())
                        {
                            yield return(null);
                        }
                    }

                    if (failed)
                    {
                        if (ShouldRetryEndPointGetRequestOrNot())
                        {
                            goto retryEndPointRequest;
                        }
                    }
                }

                // initialize AB feature.
                {
                    var cor  = InitializeAssetBundleFeature();
                    var cont = cor.MoveNext();
                    if (cont)
                    {
                        yield return(null);

                        while (cor.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                // boot app loop.
                {
                    var cor  = OnBootApplication();
                    var cont = cor.MoveNext();
                    if (cont)
                    {
                        yield return(null);

                        while (cor.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }

                // check if first boot or not.
                {
                    var cor = IsFirstBoot(
                        isFirstBoot =>
                    {
                        /*
                         *  start authentication.
                         */
                        Authenticate(
                            isFirstBoot,
                            () =>
                        {
                            /*
                             *  initialize purchase feature.
                             */
                            if (isPlayer)
                            {
                                ReloadPurchasability();
                            }
                        }
                            );
                    }
                        );

                    // run 1st loop for getting autoya instance.
                    var cont = cor.MoveNext();
                    if (cont)
                    {
                        yield return(null);

                        while (cor.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                }
            }

            mainthreadDispatcher.Commit(bootSequence());
        }