Beispiel #1
0
    private void OnAccountLogOnRequest(Role role, byte[] buffer)
    {
        AccountLogOnRequestProto  proto         = AccountLogOnRequestProto.GetProto(buffer);
        AccountLogOnResponseProto responseProto = LogOn(proto.UserName, proto.Pwd, proto.DeviceIdentifier, proto.DeviceModel);

        role.ClientSocket.SendMsg(responseProto.ToArray());
    }
    public AccountLogOnResponseProto LogOn(string userName, string pwd, string deviceIdentifier, string deviceModel)
    {
        AccountLogOnResponseProto proto = new AccountLogOnResponseProto();
        string        condition         = string.Format("[UserName]='{0}'", userName);
        AccountEntity entity            = this.GetEntity(condition);

        if (entity == null)
        {
            //账户不存在
            proto.IsSuccess = false;
            proto.MsgCode   = 103;
        }
        else
        {
            string password = entity.Pwd;
            if (!password.Equals(pwd))
            {
                //密码不相同
                proto.IsSuccess = false;
                proto.MsgCode   = 104;
            }
            else
            {
                entity.DeviceIdentifier    = deviceIdentifier;
                entity.DeviceModel         = deviceModel;
                entity.UpdateTime          = DateTime.Now;
                entity.LastLogOnServerTime = DateTime.Now;
                this.Update(entity);
                proto.IsSuccess = true;
                proto.UserId    = (int)entity.Id;
            }
        }
        return(proto);
    }
Beispiel #3
0
    private void OnAccountLogOnResponse(byte[] buffer)
    {
        AccountLogOnResponseProto proto = AccountLogOnResponseProto.GetProto(buffer);

        if (!proto.IsSuccess)
        {
            TipsUtil.ShowTextTips(1000111);
        }
        else
        {
            //登录成功
            //TipsUtil.ShowTextTips("用户编号 = " + proto.UserId);
            if (m_LogOnWindow != null)
            {
                Stat.LogOn(proto.UserId, m_LogOnWindow.IFAccount.text);
                PlayerPrefsUtil.SetAccountID(proto.UserId);
                PlayerPrefsUtil.SetAccountUserName(m_LogOnWindow.IFAccount.text);
                PlayerPrefsUtil.SetAccountPwd(m_LogOnWindow.IFPwd.text);
                m_LogOnWindow.CloseAndOpenNext(Window.GameServerEnter);
            }
            else
            {
                Stat.Register(proto.UserId, PlayerPrefsUtil.GetAccountUserName());
                WindowManager.Instance.OpenWindow(Window.GameServerEnter);
            }
            GlobalInit.Instance.AccountId       = proto.UserId;
            GlobalInit.Instance.AccountUserName = PlayerPrefsUtil.GetAccountUserName();
        }
    }
    public static AccountLogOnResponseProto GetProto(byte[] buffer)
    {
        AccountLogOnResponseProto proto = new AccountLogOnResponseProto();

        using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer))
        {
            proto.IsSuccess = ms.ReadBool();
            if (proto.IsSuccess)
            {
                proto.UserId = ms.ReadInt();
            }
            else
            {
                proto.MsgCode = ms.ReadInt();
            }
        }
        return(proto);
    }