コード例 #1
0
        /// <summary>
        /// 登陆
        /// </summary>
        private void OnClientLogin(PacketBase packet)
        {
            gs2ws.ClientLogin msg = packet as gs2ws.ClientLogin;

            string    account_name = msg.name;
            string    account_psw  = msg.psw;
            ClientUID client_uid   = msg.client_uid;

            //查询是否在缓存
            AccountData account_data = new AccountData();

            if (AccountCacheManager.Instance.GetAccountData(account_name, ref account_data))
            {
                CheckAccountLogin(client_uid, account_name, account_psw, account_data);
            }
            else
            {
                SQLLoginHandle.QueryAccountData(account_name, (data) =>
                {
                    AccountCacheManager.Instance.AddAccountData(account_name, data);
                    CheckAccountLogin(client_uid, account_name, account_psw, data);
                }
                                                );
            }
        }
コード例 #2
0
        private void OnClientLogin(PacketBase packet)
        {
            gs2db.ClientLogin msg = packet as gs2db.ClientLogin;

            ClientUID client_uid   = msg.client_uid;
            string    account_name = msg.name;
            string    account_psw  = msg.psw;

            SQLLoginHandle.QueryAccountData(account_name, (data) =>
            {
                ///1.验证账号密码
                eLoginResult result = eLoginResult.E_FAILED_UNKNOWNERROR;
                if (data.account_idx > 0)
                {
                    string md5_msg = StringUtils.GetMD5(account_psw);
                    if (data.password_md5 == md5_msg)
                    {
                        result = eLoginResult.E_SUCCESS;
                    }
                    else
                    {
                        result = eLoginResult.E_FAILED_INVALIDPASSWORD;
                    }
                }
                else
                {
                    result = eLoginResult.E_FAILED_INVALIDACCOUNT;
                }

                //if(result != eLoginResult.E_SUCCESS)
                {
                    db2gs.ClientLogin rep_msg = PacketPools.Get(db2gs.msg.CLIENT_LOGIN) as db2gs.ClientLogin;
                    rep_msg.client_uid        = client_uid;
                    rep_msg.result            = result;
                    rep_msg.account_idx       = data.account_idx;
                    rep_msg.spid = data.spid;
                    this.Send(rep_msg);
                    return;
                }

                /////2.验证登录状态
                //DBHandle.QueryLoginStatus(data.account_idx, (login_res) =>
                //{
                //    db2gs.ClientLogin rep_msg = PacketPools.Get(db2gs.msg.CLIENT_LOGIN) as db2gs.ClientLogin;
                //    rep_msg.client_uid = msg.client_uid;
                //    rep_msg.result = login_res;
                //    rep_msg.account_idx = data.account_idx;
                //    this.Send(rep_msg);
                //}
                //);
            }
                                            );
        }