Exemplo n.º 1
0
        public override void Handle(MapleBuffer mapleBuffer, CMapleClient client)
        {
            //封包: 01 05 00 61 64 6D 69 6E 05 00 61 61 61 61 61 00 00 E0 4C 68 02 E1 D9 62 59 24 00 00 00 00 BF F5 00 00 00 00

            //TODO:登陆帐号(5%)
            CUser user = new CUser()
            {
                Name  = mapleBuffer.read <string>(),
                Passw = mapleBuffer.read <string>(),
            };


            //MySqlContext context = new MySqlContext(MySqlFactory.GetFactory);//MySqlFactory.GetFactory.Query<CUser>();
            IQuery <CUser> q = MySqlFactory.GetFactory.Query <CUser>();

            CUser UserInfo = (CUser)q.Where(a => a.Name.Equals(user.Name)).FirstOrDefault();

            if (UserInfo == null)
            {
                //client.SendDatat(LoginPakcet.getLoginFailed(5));
                //TODO:自动注册功能(100%)
                client.SendDatat(LoginPakcet.ShowRegister(true));
            }
            else
            {
                if (!user.Passw.Equals(UserInfo.Passw))
                {
                    System.Console.WriteLine("密码错误..");
                    client.SendDatat(LoginPakcet.getLoginFailed(4));
                    return;
                }
                //TODO:登陆请求(50%)
                client.UserInfo = UserInfo;
                client.SendDatat(LoginPakcet.getAuthSuccessRequest(UserInfo));
                //发送全部世界..
                for (int i = 0; i < WorldEntity.GetWorld().Count; i++)
                {
                    client.SendDatat(LoginPakcet.getServerList(WorldEntity.GetWorld()[i]));
                }
                client.SendDatat(LoginPakcet.getEndOfServerList());
            }
        }