예제 #1
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());
            }
        }
예제 #2
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);
            });
        }
예제 #3
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("Error:Account doesn't exist!"));
                    return;
                }
                if (!accountCache.IsMatch(account, password))
                {
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -2);
                    Console.WriteLine(string.Format("Error:Password dosen't match!"));
                    return;
                }
                if (accountCache.IsOnline(account))
                {
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -3);
                    Console.WriteLine(string.Format("Error:Account is online!"));
                    return;
                }

                accountCache.OnLine(client, account);
                client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, 0);
                Console.WriteLine(string.Format("Sign in Successfully!"));
            });
        }
예제 #4
0
        private void Login(ClientPeer client, string account, string password)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (accountCache.IsExist(account) == false)
                {
                    //账号不存在
                    //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号错误");
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -1);
                    return;
                }
                if (accountCache.IsMatch(account, password) == false)
                {
                    //账号密码不匹配
                    //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号密码不匹配");
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -2);
                    return;
                }
                if (accountCache.IsOnline(account))
                {
                    //账号已经登录
                    //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号已登录");
                    client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -3);
                    return;
                }

                accountCache.OnLine(account, client);
                //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "登录成功");
                client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, 0);
            });
        }
예제 #5
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("登陆成功"));
            });
        }
예제 #6
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);
            });
        }
예제 #7
0
 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("不存在该账号");
         }
     });
 }