コード例 #1
0
        /// <summary>
        /// 登录请求
        /// </summary>
        /// <param name="account"></param>
        /// <param name="password"></param>
        /// <param name="isGuest"></param>
        private async Task <int> LoginRequest(string account, string password, bool isGuest = false)
        {
            int isScuess = -1;

            try
            {
                //登录网关服务器
                isScuess = await LoginHelper.OnLoginAsync(account, password, isGuest);

                if (isScuess != 0)
                {
                    Log.Debug("登陆失败!!!");

                    return(isScuess);
                }

                Log.Debug("登陆成功===========>");

                return(isScuess);
            }
            catch (Exception e)
            {
                Log.Error("无法连接到服务器: " + e.Message);

                return(isScuess);
            }
            finally
            {
            }
        }
コード例 #2
0
 public void Init(UILoginComponent com)
 {
     this.com = com;
     com.OnLoginBtnButtonClick(() =>
     {
         LoginHelper.OnLoginAsync(this.com.Account_InputField.text).Coroutine();
     });
 }
コード例 #3
0
        public static async ETVoid OnRegisterAsync(string account, string password)
        {
            try
            {
                Log.Info("注册请求");

                // 如果正在注册,就驳回登录请求,为了双重保险,点下登录按钮后,收到服务端响应之前将不能再点击
                if (isRegistering)
                {
                    return;
                }

                if (account == "" || password == "")
                {
                    Game.EventSystem.Run(EventIdType.ShowLoginInfo, "账号或密码不能为空");
                    Log.Info("信息显示完毕");
                    FinalRun();
                    return;
                }
                isRegistering = true;
                // 创建一个ETModel层的Session
                ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>()
                                          .Create(GlobalConfigComponent.Instance.GlobalProto.Address);
                // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息
                realmSession = ComponentFactory.Create <Session, ETModel.Session>(session);

                Game.EventSystem.Run(EventIdType.ShowLoginInfo, "正在注册");

                // 发送登录请求,账号,密码均为传来的参数
                R2C_Register r2CRegister = (R2C_Register)await realmSession.Call(new C2R_Register()
                {
                    Account = account, Password = password
                });

                if (r2CRegister.Error == ErrorCode.ERR_AccountAlreadyRegister)
                {
                    Game.EventSystem.Run(EventIdType.ShowLoginInfo, "注册失败,账号已被注册");
                    FinalRun();
                    return;
                }
                LoginHelper.OnLoginAsync(account, password).Coroutine();
                FinalRun();
            }
            catch (Exception e)
            {
                Game.EventSystem.Run(EventIdType.ShowLoginInfo, "注册异常");
                FinalRun();
            }
        }
コード例 #4
0
        /// <summary>
        /// 登录按钮
        /// </summary>
        private async ETVoid OnLogin()
        {
            //获取账号
            if (!int.TryParse(this.account.GetComponent <InputField>().text, out int account))
            {
                Log.Error("错误,账号不是数字");
                loginFail.SetActive(true);
                return;
            }
            string password = this.password.GetComponent <InputField>().text;


            if (waitPackeg)
            {
                return;
            }
            waitPackeg = true;
            try
            {
                //发送请求登录的包
                G2C_Login g2CLogin = (G2C_Login)await loginSession.Call(new C2G_Login()
                {
                    Account = account, Password = password
                });

                if (g2CLogin.LoginFail)
                {
                    //登录成功
                    loginFail.SetActive(false);
                    LoginHelper.OnLoginAsync(account);
                }
                else
                {
                    loginFail.SetActive(true);
                    waitPackeg = false;
                }
            }
            catch (Exception e)
            {
                Debug.LogError("链接服务器失败: " + e);

                ServerFail();
            }
        }
コード例 #5
0
 public void OnLogin()
 {
     LoginHelper.OnLoginAsync(this.account.GetComponent <InputField>().text).Coroutine();
 }
コード例 #6
0
 /// <summary>
 /// 前往训练营
 /// </summary>
 /// <param name="self"></param>
 public void ToTestSceneBtnBtnOnClick(FUILogin self)
 {
     self.Btn_Login.self.visible = false;
     LoginHelper.OnLoginAsync("Test123", "Test123").Coroutine();
 }
コード例 #7
0
 public void LoginBtnOnClick(FUILogin self)
 {
     self.Btn_Login.self.visible = false;
     LoginHelper.OnLoginAsync(self.accountText.text, self.passwordText.text).Coroutine();
 }
コード例 #8
0
ファイル: UILoginComponent.cs プロジェクト: luwenyiCC/ET
 public void OnLogin()
 {
     LoginHelper.OnLoginAsync(this.account.text, this.password.text).Coroutine();
 }
コード例 #9
0
 public void OnLogin()
 {
     bgImage.GetComponent <Image>().color = Color.blue;
     LoginHelper.OnLoginAsync(this.account.GetComponent <InputField>().text).Coroutine();
 }
コード例 #10
0
        /// <summary>
        /// 登录请求
        /// </summary>
        /// <param name="account"></param>
        /// <param name="password"></param>
        /// <param name="isGuest"></param>
        private async Task <int> LoginRequest(string account, string password, bool isGuest = false)
        {
            int isScuess = -1;

            Game.PopupComponent.ShowLoadingLockUI();
            _isRequest = true;
            try
            {
                //登录网关服务器
                if (isGuest)
                {
                    isScuess = await LoginHelper.OnLoginAsync(account, password, isGuest);
                }
                else
                {
                    isScuess = await LoginHelper.OnLoginAsyncToken(account, password);
                }
                if (isScuess != 0)
                {
                    _isRequest = false;
                    if (isGuest && isScuess == ErrorCode.ERR_AccountDoesnExist)
                    {
                        AccountIsNotExist();
                        Log.Debug(DataCenterComponent.Instance.tipInfo.AccountNotExistTip);
                        OnVisitorLoginButton();
                        return(isScuess);
                    }
                    Game.PopupComponent.CloseLoadingLockUI();
                    if (isScuess == 210006)
                    {
                        //账号不存在,删除本地存储的账号
                        PlayerPrefs.DeleteKey($"Account0{_CurrChooseAccountIndex}");
                        _ChooseDialog.SetActive(false);
                    }
                    if (isScuess == 210005)
                    {
                        _LoginDialog.SetActive(true);
                        SetLoginDialog(true);
                        _MobileInputField.text = account;
                        _CodeInputField.text   = "";
                        PlayerPrefs.DeleteKey($"Account0{_CurrChooseAccountIndex}");
                        _ChooseDialog.SetActive(false);
                    }
                    return(isScuess);
                }
                var openInstall = ETModel.Game.Scene.GetComponent <OpenInstallComponent>();
                openInstall.getInstall();

                //G2C_ActivityIsOpenReturn_Res resp = (G2C_ActivityIsOpenReturn_Res)await SessionComponent.Instance.Session.Call(new C2G_ActivityIsOpenAsk_Req());

                Game.EventSystem.Run(EventIdType.LoginPokerFinish);
                Game.EventSystem.Run(EventIdType.CreateGameLobby);
                _isRequest = false;
                Game.PopupComponent.CloseLoadingLockUI();
                return(isScuess);
            }
            catch (Exception e)
            {
                _isRequest = false;
                Log.Error("无法连接到服务器: " + e.Message);
                Game.PopupComponent.ShowMessageBox(DataCenterComponent.Instance.tipInfo.ConnectServerFailTip);
                return(isScuess);
            }
            finally
            {
                _isRequest = false;
                Game.PopupComponent.CloseLoadingLockUI();
            }
        }