/**
             *                  http response rooting of boot.
             */
            private void OnBootResult(string tokenConnectionId, Dictionary <string, string> responseHeader, int responseCode, string resultData, string errorReason)
            {
                if (forceFailFirstBoot)
                {
                    responseCode = AuthSettings.FORCE_FAIL_FIRSTBOOT_CODE;
                    errorReason  = "failed by forceFailFirstBoot = true.";
                }

                autoya.HttpResponseHandling(
                    tokenConnectionId,
                    responseHeader,
                    responseCode,
                    resultData,
                    errorReason,
                    (succeededConId, succeededData) =>
                {
                    var tokenData = succeededData as string;

                    mainthreadDispatcher.Commit(OnBootSucceeded(responseHeader, tokenData));
                },
                    (failedConId, failedCode, failedReason, autoyaStatus) =>
                {
                    /*
                     *                              maintenance or auth failed is already handled.
                     */
                    if (autoyaStatus.inMaintenance || autoyaStatus.isAuthFailed)
                    {
                        return;
                    }

                    // other errors.

                    // reached to the max retry for boot access.
                    if (bootRetryCount == AuthSettings.AUTH_FIRSTBOOT_MAX_RETRY_COUNT)
                    {
                        Debug.Log("retry maxで死んでる");
                        authState = AuthState.BootFailed;
                        onBootFailed(failedCode, failedReason);
                        return;
                    }

                    bootRetryCount++;
                    mainthreadDispatcher.Commit(BootRetryCoroutine());
                }
                    );
            }
            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());
            }
示例#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());
        }
示例#4
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();

            mainthreadDispatcher.Commit(
                OnBootApplication(),
                IsFirstBoot(
                    isFirstBoot =>
            {
                InitializeAppManifest();

                InitializeAssetBundleFeature();

                /*
                 *  start authentication.
                 */
                Authenticate(
                    isFirstBoot,
                    () =>
                {
                    /*
                     *  initialize purchase feature.
                     */
                    if (isPlayer)
                    {
                        ReloadPurchasability();
                    }
                }
                    );
            }
                    )
                );
        }