Ejemplo n.º 1
0
        public void GetSession(string token)
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            TacoConfig.print("Attempting auto login with token = " + token);

            Action <string> success = (string data) => {
                TacoConfig.print("data= " + data);
                SessionResult r = JsonUtility.FromJson <SessionResult>(data);
                if (r.success)
                {
                    TacoConfig.print("Success = " + r);

                    TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage01);
                    TacoManager.UpdateUser(r, token);
                    if (r.msg == "in")
                    {
                        TacoManager.OpenModal("Login success", "Welcome back to game taco! ");
                    }
                    else
                    {
                        TacoManager.OpenModal("Login success", "You get " + r.value + " taco token for login today! ");
                    }
                }
                else
                {
                    //TacoConfig.print("Error = " + r.message );

                    TacoManager.CloseMessage();

                    TacoManager.SetPreferenceString(UserPreferences.userToken, null);
                    TacoManager.SetPreference(UserPreferences.autoLogin, 0);
                    TacoManager.ShowPanel(PanelNames.LoginPanel);

                    if (!string.IsNullOrEmpty(r.message))
                    {
                        TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, r.message);
                    }
                }
            };

            Action <string, string> fail = (string data, string error) => {
                TacoConfig.print("Error on Login : "******"Error : " + error);
                }

                TacoManager.CloseMessage();

                string msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error);

                // TODO : have the message 'Cannot Reach Destination Host' - read 'No Internet Connection'  -- something more clear?
                TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage01 + "\n\n" + msg);
            };
            string url = "api/session/detail/" + TacoConfig.SiteId;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }
Ejemplo n.º 2
0
        public void GetSession(string token)
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            TacoConfig.print("Attempting auto login with token = " + token);

            Action <string> success = (string data) => {
                TacoConfig.print("data= " + data);
                SessionResult r = JsonUtility.FromJson <SessionResult>(data);
                if (r.success)
                {
                    TacoConfig.print("Success = " + r);

                    TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage01);
                    TacoManager.UpdateUser(r, token);
                }
                else
                {
                    //TacoConfig.print("Error = " + r.message );

                    TacoManager.CloseMessage();
                    TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage01);
                }
            };

            Action <string, string> fail = (string data, string error) => {
                TacoConfig.print("Error on Login : "******"Error : " + error);
                }

                TacoManager.CloseMessage();

                string msg = data + (string.IsNullOrEmpty(error) ? "" : " : " + error);

                // TODO : have the message 'Cannot Reach Destination Host' - read 'No Internet Connection'  -- something more clear?
                TacoManager.OpenModal(TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage01 + "\n\n" + msg);
            };

            string url = "api/session/detail/" + TacoConfig.SiteId;

            this.Get(url, success, fail);
        }
Ejemplo n.º 3
0
        public void GetSession(string token)
        {
            TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage00);

            Action <string> success = (string data) => {
                SessionResult r = JsonUtility.FromJson <SessionResult> (data);
                if (r.success)
                {
                    Debug.Log("session: " + data);
                    BalanceManager.Instance.SetRemainingValue(r.remainingClaim, r.login_count);
                    TacoManager.OpenMessage(TacoConfig.TacoLoginStatusMessage01);
                    TacoManager.UpdateUser(r, token);
                    if (r.msg == "in")
                    {
                        //Debug.LogWarning("No longer implemented");
                    }
                    else
                    {
                        TacoManager.OpenModalDailyTokenPanel(r.value);
                    }
                }
                else
                {
                    TacoManager.CloseMessage();
                    TacoManager.SetPreferenceString(UserPreferences.userToken, null);
                    TacoManager.SetPreference(UserPreferences.autoLogin, 0);
                    TacoManager.ShowPanel(PanelNames.LoginPanel);

                    if (!string.IsNullOrEmpty(r.message))
                    {
                        TacoManager.OpenModalLoginFailedPanel(r.message);
                    }
                }
            };

            Action <string, string> fail = (string data, string error) => {
                if (!string.IsNullOrEmpty(data))
                {
                    try {
                        SystemError r = JsonUtility.FromJson <SystemError> (data);
                        if (r.verErr)
                        {
                            //version error
                            TacoManager.OpenModalIncorrectVersionPanel(r.message);
                        }
                        else
                        {
                            string msg = r.message;
                            if (string.IsNullOrEmpty(msg))
                            {
                                msg = TacoConfig.TacoLoginErrorEmailPassword;
                            }
                            TacoManager.OpenModalLoginFailedPanel(msg);
                        }
                    } catch (Exception) {
                        TacoManager.OpenModalLoginFailedPanel(TacoConfig.Error);
                    }
                }
                else
                {
                    TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword);
                }
                TacoManager.CloseMessage();
            };
            string url = "api/session/detail/" + TacoSetup.Instance.SiteId;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }