Esempio n. 1
0
        /// <summary>
        /// 创建账号
        /// </summary>
        /// <param name="token"></param>
        /// <param name="dto"></param>
        public void Create(UserToken token, AccountDto dto)
        {
            //验证账号密码的合法性
            if (string.IsNullOrEmpty(dto.Account) || string.IsNullOrEmpty(dto.Password))
            {
                //当账号或者密码为空的时候
                //因为下面内容经常使用,所以就建一个扩展UserToken的类,内置这些内容;
                //NetModle modle = new NetModle();
                //modle.Type = Protocol.Common;
                //modle.Command = CommonProtocol.S2C_ErrorCode;
                //modle.Message = ErrorCode.AccountPasswordIsNotSafe;//主要目的!把错误信息打包进modle中,发给客户端看
                //token.Send(modle);

                ExUserToken.Send(token, ErrorCode.AccountPasswordIsNotSafe);
                return;
            }
            //验证账号是否被注册,需要调用缓存层进行验证
            if (accountCache.HasAccount(dto.Account))
            {
                token.Send(ErrorCode.AccountHasRegister);
                return;
            }

            //调用缓存层创建账号
            accountCache.Add(token, dto);

            //通知客户端注册账号成功
            token.Send(Protocol.Login, LoginProtocol.S2C_Login);
        }
Esempio n. 2
0
        private Account CreateNewAccount(string name, string password)
        {
            var ac = Account.CreateAccount(name, password, 20);

            AccountCache.Add(ac);
            Directory.CreateDirectory(Directory.GetParent(accountFilePath).FullName);
            GameSerializer.SaveToFile(accountFilePath, AccountCache);
            return(ac);
        }
Esempio n. 3
0
 private void OnRegister(MOBAClient client, string account, string password)
 {
     //无效检测
     if (account == null || password == null)
     {
         return;
     }
     //重复检测
     if (accountCache.Has(account))
     {
         Send(client, OperationCode.AccountCode, OpAccount.Register, -1, "账号已存在");
         return;
     }
     accountCache.Add(account, password);
     Send(client, OperationCode.AccountCode, OpAccount.Register, 0, "注册成功");
 }
Esempio n. 4
0
 /// <summary>
 /// 注册处理
 /// </summary>
 /// <param name="acc"></param>
 /// <param name="pwd"></param>
 private void OnRegister(MobaClient client, string acc, string pwd)
 {
     MobaApplication.LogInfo("aa");
     //无效检测
     if (acc == null || pwd == null)
     {
         return;
     }
     //重复检测
     if (cache.Has(acc))
     {
         this.Send(client, OpCode.AccountCode, OpAccount.Register, -1, "账号重复");
         return;
     }
     //添加账号
     cache.Add(acc, pwd);
     this.Send(client, OpCode.AccountCode, OpAccount.Register, 0, "注册成功");
 }
Esempio n. 5
0
        /// <summary>
        /// 注册处理
        /// </summary>
        /// <param name="acc"></param>
        /// <param name="pwd"></param>
        private void onRegister(MobaClient client, string acc, string pwd)
        {
            //无效检测
            if (string.IsNullOrEmpty(acc) ||
                string.IsNullOrEmpty(pwd))
            {
                return;
            }
            //重复检测
            if (cache.Has(acc))
            {
                Send(client, OpCode.AccountCode, OpAccount.Register, -1, "账号重复");
                return;
            }

            cache.Add(acc, pwd);
            Send(client, OpCode.AccountCode, OpAccount.Register, 0, "注册成功");
        }
Esempio n. 6
0
        /// <summary>
        /// 注册处理
        /// </summary>
        /// <param name="acc"></param>
        /// <param name="pwd"></param>
        private void OnRegister(MobaClient client, string acc, string pwd)
        {
            //无效检查
            if (acc == null || pwd == null)
            {
                return;
            }

            if (cache.Has(acc))
            {
                this.Send(client, OpCode.AccountCode, OpAccount.Register, -1, "账号重复");
                return;
            }

            //添加账号
            cache.Add(acc, pwd);
            this.Send(client, OpCode.AccountCode, OpAccount.Register, 0, "注册成功");
        }
Esempio n. 7
0
        private int Register(RegisterUserInfo userInfo)
        {
            if (userInfo.Username == null ||
                userInfo.Password == null ||
                userInfo.Nickname == null ||
                userInfo.Username.Equals("") ||
                userInfo.Password.Equals("") ||
                userInfo.Nickname.Equals("") ||
                cacheInstance.HasAccount(userInfo.Username))
            {
                return(Protocol.COMMAND_REGISTER_FAIL);
            }

            //写入数据库
            AccountTable.AddNewAccount(userInfo);
            cacheInstance.Add(userInfo.Username, userInfo.Password);
            userCacheInstance.addUser(userInfo);
            return(Protocol.COMMAND_REGISTER_SUCCESS);
        }
Esempio n. 8
0
        /// <summary>
        /// 注册处理
        /// </summary>
        private void register(MyClient client, AccountDto account)
        {
            OperationResponse response =
                new OperationResponse((byte)OpCode.Account, new Dictionary <byte, object>());

            response.Parameters[80] = AccountCode.Register;
            if (cache.HasAccount(account.Account))
            {
                response.DebugMessage = "账号已存在.";
                response.ReturnCode   = -1;
                client.SendOperationResponse(response, new SendParameters());
                return;
            }
            else
            {
                cache.Add(account.Account, account.Password);

                response.DebugMessage = "注册成功.";
                response.ReturnCode   = 0;
                client.SendOperationResponse(response, new SendParameters());
            }
        }