예제 #1
0
        void RegistConfirm()
        {
            mConfirmBtn
            .OnClickAsOptional()

            .SelectMany(_ => {
                if (mPasswordFld.text != mPasswordConfirmFld.text)
                {
                    throw new System.Exception("missmatch password and confirm password. please check that a both is matched.");
                }

                return(DC.CNetwork.s.platform.account.Authentication());
            })
            .SelectMany(err => {
                if ("ok" == err)
                {
                    var signup_param = new Sas.Data.AccountSignupParam();
                    var email        = new System.Security.SecureString();
                    mAccountIDFld.text.ToList().ForEach(c => email.AppendChar(c));
                    signup_param.email = email;

                    var password = new System.Security.SecureString();
                    mPasswordFld.text.ToList().ForEach(c => password.AppendChar(c));
                    signup_param.password = password;

                    return(DC.CNetwork.s.platform.account.SignUp(signup_param));
                }
                else
                {
                    throw new Sas.Exception(Sas.ERRNO.MESSAGE.ToErrCode(), "make sure that authentication.");
                }
            })
            .Repeat()
            .Subscribe(ret => {
                CModal.Make("", "Wellcome to Dot chat!!").onHandleBtn += (CPopup arg1, string arg2) => arg1.Close();
                BackToLogin();
            },
                       err => {
                if (!CNetwork.s.ContainHandleErr(err))
                {
                    if (string.IsNullOrEmpty(err.Message))
                    {
                        CModal.Make("", err.ToErrstrOfSas()).onHandleBtn += (CPopup arg1, string arg2) => arg1.Close();
                    }
                    else
                    {
                        CModal.Make("", err.Message).onHandleBtn += (CPopup arg1, string arg2) => arg1.Close();
                    }
                }
                RegistConfirm();
            });
        }
예제 #2
0
        void RegistLogin()
        {
            mLoginBtn
            .OnClickAsOptional()
            .SelectMany(_ => {
                return(DC.CNetwork.s.platform.account.Authentication());
            })
            .SelectMany(err => {
                if ("ok" == err)
                {
                    var login_param = new Sas.Data.AccountLoginParam();
                    var email       = new System.Security.SecureString();
                    mAccountIDFld.text.ToList().ForEach(c => email.AppendChar(c));
                    login_param.email = email;

                    var password = new System.Security.SecureString();
                    mPasswordFld.text.ToList().ForEach(c => password.AppendChar(c));
                    login_param.password = password;

                    return(DC.CNetwork.s.platform.account.Login(login_param));
                }
                else
                {
                    throw new Sas.Exception(Sas.ERRNO.MESSAGE.ToErrCode(), "make sure that authentication.");
                }
            })
            .SelectMany(_ => DC.CNetwork.s.platform.account.AccessOpen())
            .SelectMany(_ => DC.CNetwork.s.platform.account.DumpAutoLogin(Config.acccount_file_name))
            .Repeat()
            .Subscribe(ret => {
                UnityEngine.SceneManagement.SceneManager.LoadScene("Dotchatti");
//                        CModal.Make ("", "success").onHandleBtn += (CPopup arg1, string arg2) => arg1.Close ();
            },
                       err => {
                if (!CNetwork.s.ContainHandleErr(err))
                {
                    if (string.IsNullOrEmpty(err.Message))
                    {
                        CModal.Make("", err.ToErrstrOfSas()).onHandleBtn += (CPopup arg1, string arg2) => arg1.Close();
                    }
                    else
                    {
                        CModal.Make("", err.Message).onHandleBtn += (CPopup arg1, string arg2) => arg1.Close();
                    }
                }
                RegistLogin();
            });
        }
예제 #3
0
        public static CCommonPopup Make(CCommonPopup.Config config)
        {
            var prefab = Resources.Load(config.prefab);

            if (prefab == null)
            {
                Debug.unityLogger.LogError(
                    System.Reflection.MethodBase.GetCurrentMethod().Name,
                    string.Format("cannot find prefab('{0}')", config.prefab));
                return(null);
            }

            var inst  = UnityEditor.PrefabUtility.InstantiatePrefab(prefab) as GameObject;
            var popup = CModal.Make <CCommonPopup> (inst.transform);

            popup.SetConfig(config);
            return(popup);
        }
예제 #4
0
        void Awake()
        {
            platform = new Sas.User(Config.host_server, "cert");
            chatti   = new DC.COMPONENET.Chatti(platform.context);

            AddHnadleErr(new System.Text.RegularExpressions.Regex(".*"), (erq, err) => {
                CCommonPopup popup = null;
                if (CModal.CountIf(p => p.kind == "popup_network_alram") > 0)
                {
                    return;
                }
                if (string.IsNullOrEmpty(err.Message))
                {
                    popup = CModal.Make("", err.ToErrstrOfSas());
                }
                else
                {
                    popup = CModal.Make("", err.Message);
                }

                popup.onHandleBtn += (p, str) => p.Close();
                popup.kind         = "popup_network_alram";
            });

            platform.requester_post_handler += (req, res, err) => {
                if (err == null)
                {
                    return;
                }
                var exception = err as Sas.Exception;
                var desc      = Enum.GetName(typeof(Sas.ERRNO), exception != null ? exception.ToErrnoOfSas() : Sas.ERRNO.UNKNOWN);

                foreach (var pr in mErrHandles)
                {
                    if (pr.Key.IsMatch(desc))
                    {
                        pr.Value(req, err);
                    }
                }
            };
        }