示例#1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="client"></param>
        /// <param name="account"></param>
        /// <param name="password"></param>
        private void login(ClientPeer client, string account, string password)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (!accountCache.IsExist(account))
                {
                    //表示账号不存在
                    //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号不存在");
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -1);
                    return;
                }

                if (accountCache.IsOnline(account))
                {
                    //表示账号在线
                    //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号在线");
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -2);
                    return;
                }

                if (!accountCache.IsMatch(account, password))
                {
                    //表示账号密码不匹配
                    //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号密码不匹配");
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -3);
                    return;
                }

                //登陆成功
                accountCache.Online(client, account);
                //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "登陆成功");
                client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, 0);
            });
        }
示例#2
0
        private void Login(ClientPeer client, string account, string password)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (!accountCache.IsExist(account))
                {
                    //帐号不存在
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -1);
                    Console.WriteLine(string.Format("错误:帐号不存在"));
                    return;
                }

                if (!accountCache.IsMatch(account, password))
                {
                    //帐号密码不匹配
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -2);
                    Console.WriteLine(string.Format("错误:帐号密码不匹配"));
                    return;
                }

                if (accountCache.IsOnline(account))
                {
                    //帐号在线
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -3);
                    Console.WriteLine(string.Format("错误:帐号在线"));
                    return;
                }

                //登陆成功
                accountCache.Online(client, account);
                client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, 0);
                Console.WriteLine(string.Format("登陆成功"));
            });
        }
示例#3
0
        /// <summary>
        /// 登录处理
        /// </summary>
        private void login(MyClient client, AccountDto account)
        {
            OperationResponse response =
                new OperationResponse((byte)OpCode.Account, new Dictionary <byte, object>());

            response.Parameters[80] = AccountCode.Login;
            if (!cache.IsMatch(account.Account, account.Password))
            {
                response.DebugMessage = "账号密码不匹配.";
                response.ReturnCode   = -1;
                client.SendOperationResponse(response, new SendParameters());
                return;
            }
            else if (cache.IsOnline(client))
            {
                response.DebugMessage = "玩家在线.";
                response.ReturnCode   = -2;
                client.SendOperationResponse(response, new SendParameters());
                return;
            }
            else
            {
                cache.Online(client, account.Account, account.Password);
                response.DebugMessage = "登陆成功.";
                response.ReturnCode   = 0;
                client.SendOperationResponse(response, new SendParameters());
            }
        }
示例#4
0
        /// <summary>
        /// 登录账号,返回一个ErrorCode,用户登录情况的枚举
        /// </summary>
        /// <param name="token"></param>
        /// <param name="account"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public ErrorCode Login(UserToken token, string account, string password)
        {
            //验证账号密码的合法性
            if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(password))
            {
                return(ErrorCode.AccountPasswordIsNotSafe);
            }
            //验证账号是否注册
            if (!accountCache.HasAccount(account))
            {
                return(ErrorCode.NotHasAccount);
            }

            //验证是否已经登录
            if (accountCache.IsOnline(token))
            {
                return(ErrorCode.HasLogin);
            }
            //验证账号密码是否匹配
            if (!accountCache.Matching(account, password))
            {
                return(ErrorCode.NotMatch);
            }
            //上线
            accountCache.Online(token, account);
            return(ErrorCode.Success);
        }
示例#5
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="clientPeer"></param>
        /// <param name="acc"></param>
        /// <param name="pwd"></param>
        public void Login(ClientPeer clientPeer, string acc, string pwd)
        {
            SingleExcute.Instance.Excute(() =>
            {
                if (!accountCache.IsExit(acc))
                {
                    //账号不存在
                    clientPeer.Send(OpCode.ACCOUNT, AccountSubCode.LOGIN_SRES, "账号不存在");
                    return;
                }
                if (accountCache.IsOnline(acc))
                {
                    //账号在线
                    clientPeer.Send(OpCode.ACCOUNT, AccountSubCode.LOGIN_SRES, "账号在线");
                    return;
                }

                if (!accountCache.IsMactch(acc, pwd))
                {
                    //账号密码不匹配
                    clientPeer.Send(OpCode.ACCOUNT, AccountSubCode.LOGIN_SRES, "密码错误");
                    return;
                }

                accountCache.Online(acc, clientPeer);
                clientPeer.Send(OpCode.ACCOUNT, AccountSubCode.LOGIN_SRES, "登录成功");
            });
        }
示例#6
0
 private int Login(UserToken token, string username, string password)
 {
     if (username == null ||
         password == null ||
         username.Equals("") ||
         password.Equals("") ||
         !cacheInstance.HasAccount(username) ||
         cacheInstance.IsOnline(username) ||
         !cacheInstance.Match(username, password))
     {
         return(Protocol.COMMAND_LOGIN_FAIL);
     }
     cacheInstance.Online(token, username);
     return(Protocol.COMMAND_LOGIN_SUCCESS);
 }
示例#7
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="client"></param>
        /// <param name="info"></param>
        private void Login(ClientPeer client, UserInfoDto info)
        {
            SingleExecute.Instance.Execute(() =>
            {
                var msg = new SocketMsg
                {
                    OpCode  = MsgType.Account,
                    SubCode = AccountCode.Login_Check,
                    State   = AccountCode.Success
                };
                if (!accountCache.IsExist(info.Account))
                {
                    msg.State = AccountCode.AccountDoesNotExist;
                    client.Send(msg);
                    return;
                }

                if (accountCache.IsOnline(info.Account))
                {
                    msg.State = AccountCode.AccountOnline;
                    client.Send(msg);
                    return;
                }

                if (!accountCache.IsMatch(info.Account, info.Password))
                {
                    msg.State = AccountCode.AccountPasswordDoesNotMatch;
                    client.Send(msg);
                    return;
                }
                //查询数据库是否存在当前账号
                //var db = DatabaseHelper.GetInstance();
                //var userInfo = db.Queryable<UserInfo>().Where(w => w.Account == info.Account && w.Password == info.Password).First();
                //if (userInfo == null)
                //{
                //    msg.value = MsgType.AccountPasswordDoesNotMatch;
                //    client.Send(msg);
                //    return;
                //}
                //登陆成功 放入缓存
                accountCache.Online(client, info.Account);
                client.Send(msg);
            });
        }
 private void Login(ClientPeer client, string account, string password)
 {
     SingleExecute.Instance.Execute(() => {
         if (accountCache.IsExist(account))  //存在该账号
         {
             //然后判断密码
             if (accountCache.IsMatch(account, password))
             {
                 //密码正确
                 //client.StartSend(OpCode.ACCOUNT, AccountCode.LOGIN, "密码正确...");
                 if (accountCache.IsOnline(account))
                 {
                     //账号在线
                     client.StartSend(OpCode.ACCOUNT, AccountCode.LOGIN, "账号已经在线");
                     Console.WriteLine("账号已经在线...");
                 }
                 else
                 {
                     //登录成功
                     accountCache.Online(account, client);
                     client.StartSend(OpCode.ACCOUNT, AccountCode.LOGIN, "登录成功");
                     Console.WriteLine("登录成功...");
                 }
             }
             else
             {
                 //密码输入错误
                 client.StartSend(OpCode.ACCOUNT, AccountCode.LOGIN, "密码输入错误");
                 Console.WriteLine("密码输入错误");
             }
         }
         else
         {
             //不存在该账号
             client.StartSend(OpCode.ACCOUNT, AccountCode.LOGIN, "不存在该账号");
             Console.WriteLine("不存在该账号");
         }
     });
 }
示例#9
0
 /// <summary>
 /// 登录处理
 /// </summary>
 /// <param name="acc"></param>
 /// <param name="pwd"></param>
 private void onLogin(MobaClient client, string acc, string pwd)
 {
     if (acc == null || pwd == null)
     {
         return;
     }
     //验证在线...
     if (cache.IsOnline(acc))
     {
         this.Send(client, OpCode.AccountCode, OpAccount.Login, -1, "玩家在线");
         return;
     }
     if (cache.Match(acc, pwd))
     {
         cache.Online(acc, client);
         this.Send(client, OpCode.AccountCode, OpAccount.Login, 0, "登录成功");
     }
     else
     {
         this.Send(client, OpCode.AccountCode, OpAccount.Login, -2, "账号或密码错误");
     }
 }
示例#10
0
        /// <summary>
        /// 登录处理
        /// </summary>
        /// <param name="acc"></param>
        /// <param name="pwd"></param>
        private void onLogin(MobaClient client, string acc, string pwd)
        {
            if (string.IsNullOrEmpty(acc) || string.IsNullOrEmpty(pwd))
            {
                return;
            }
            //验证在线...
            if (cache.isOnline(acc))
            {
                Send(client, OpCode.AccountCode, OpAccount.Login, -1, "玩家在线");
                return;
            }
            bool res = cache.Match(acc, pwd);

            if (res)
            {
                cache.Online(acc, client);
                Send(client, OpCode.AccountCode, OpAccount.Login, 0, "登录成功");
            }
            else
            {
                Send(client, OpCode.AccountCode, OpAccount.Login, -2, "账号或密码错误");
            }
        }