public override void Handle(LoginSession session, PacketReader packet)
        {
            session.Send(BannerListPacket.SetBanner());
            session.Send(ServerListPacket.SetServers(ServerName, ServerIPs));

            List <Player> characters = DatabaseManager.GetAccountCharacters(session.AccountId);

            session.Send(CharacterListPacket.SetMax(4, 6));
            session.Send(CharacterListPacket.StartList());
            // Send each character data
            session.Send(CharacterListPacket.AddEntries(characters));
            session.Send(CharacterListPacket.EndList());
        }
Beispiel #2
0
        public override void Handle(LoginSession session, PacketReader packet)
        {
            byte   mode     = packet.ReadByte();
            string username = packet.ReadUnicodeString();
            string password = packet.ReadUnicodeString();

            // Hash the password with BCrypt
            string passwordHash = BCrypt.Net.BCrypt.HashPassword(password);

            // TODO: Change authenticate to return bool and add packet for wrong password
            Account account = DatabaseManager.Authenticate(username, password);

            // Auto add new accounts
            if (account == default)
            {
                account = new Account(username, passwordHash);
            }

            Logger.Debug($"Logging in with account ID: {account.Id}");
            session.AccountId = account.Id;

            switch (mode)
            {
            case 1:
                PacketWriter pWriter = PacketWriter.Of(SendOp.NPS_INFO);
                pWriter.WriteLong();
                pWriter.WriteUnicodeString(account.Username);

                session.Send(pWriter);

                List <Banner> banners = DatabaseManager.GetBanners();
                session.Send(BannerListPacket.SetBanner(banners));
                session.Send(ServerListPacket.SetServers(ServerName, ServerIPs));
                break;

            case 2:
                List <Player> characters = DatabaseManager.GetAccountCharacters(session.AccountId);

                Logger.Debug($"Initializing login with account id: {session.AccountId}");
                session.Send(LoginResultPacket.InitLogin(session.AccountId));
                session.Send(UgcPacket.SetEndpoint("http://127.0.0.1/ws.asmx?wsdl", "http://127.0.0.1"));
                session.Send(CharacterListPacket.SetMax(account.CharacterSlots));
                session.Send(CharacterListPacket.StartList());
                // Send each character data
                session.Send(CharacterListPacket.AddEntries(characters));
                session.Send(CharacterListPacket.EndList());
                break;
            }
        }
Beispiel #3
0
        public override void Handle(LoginSession session, PacketReader packet)
        {
            byte   mode = packet.ReadByte();
            string user = packet.ReadUnicodeString();
            string pass = packet.ReadUnicodeString();

            logger.Debug($"Logging in with user:{user} pass:{pass}");
            // TODO: From this user/pass lookup we should be able to find the accountId
            if (string.IsNullOrEmpty(user) && string.IsNullOrEmpty(pass))
            {
                //session.AccountId = StaticAccountStorage.DEFAULT_ACCOUNT;

                logger.Info($"No user and password provide logging in with root account ");
            }
            else
            {
                logger.Info($"Success, with any string in user and pass");
                //session.AccountId = StaticAccountStorage.SECONDARY_ACCOUNT;
            }



            switch (mode)
            {
            case 1:
                session.Send(PacketWriter.Of(SendOp.NPS_INFO).WriteLong().WriteUnicodeString(""));
                session.Send(BannerListPacket.SetBanner());
                session.Send(ServerListPacket.SetServers(serverName, serverIps));
                break;

            case 2:
                List <Player> characters = new List <Player>();

                /*
                 * foreach (long characterId in accountStorage.ListCharacters(session.AccountId)) {
                 *  characters.Add(accountStorage.GetCharacter(characterId));
                 * }*/

                Console.WriteLine("Initializing login with " + session.AccountId);
                session.Send(LoginResultPacket.InitLogin(session.AccountId));
                session.Send(UgcPacket.SetEndpoint("http://127.0.0.1/ws.asmx?wsdl", "http://127.0.0.1"));
                session.Send(CharacterListPacket.SetMax(4, 6));
                session.Send(CharacterListPacket.StartList());
                // Send each character data
                session.Send(CharacterListPacket.AddEntries(characters));
                session.Send(CharacterListPacket.EndList());
                break;
            }
        }
Beispiel #4
0
        public override void Handle(LoginSession session, PacketReader packet)
        {
            byte   mode     = packet.ReadByte();
            string username = packet.ReadUnicodeString();
            string password = packet.ReadUnicodeString();


            Account account = DatabaseManager.GetAccount(username, password);

            // Auto add new accounts
            if (account == default)
            {
                account = new Account(GuidGenerator.Long(), username, password);
                if (!DatabaseManager.Insert(account))
                {
                    throw new ArgumentException("Could not create account");
                }
            }

            Logger.Debug($"Logging in with account ID: {account.Id}");
            session.AccountId = account.Id;

            switch (mode)
            {
            case 1:
                PacketWriter pWriter = PacketWriter.Of(SendOp.NPS_INFO);
                pWriter.WriteLong();
                pWriter.WriteUnicodeString("");

                session.Send(pWriter);
                session.Send(BannerListPacket.SetBanner());
                session.Send(ServerListPacket.SetServers(ServerName, ServerIPs));
                break;

            case 2:
                List <Player> characters = DatabaseManager.GetAccountCharacters(session.AccountId);

                Logger.Debug($"Initializing login with account id: {session.AccountId}");
                session.Send(LoginResultPacket.InitLogin(session.AccountId));
                session.Send(UgcPacket.SetEndpoint("http://127.0.0.1/ws.asmx?wsdl", "http://127.0.0.1"));
                session.Send(CharacterListPacket.SetMax(4, 6));
                session.Send(CharacterListPacket.StartList());
                // Send each character data
                session.Send(CharacterListPacket.AddEntries(characters));
                session.Send(CharacterListPacket.EndList());
                break;
            }
        }
        public override void Handle(LoginSession session, PacketReader packet) {
            session.Send(BannerListPacket.SetBanner());
            session.Send(ServerListPacket.SetServers(serverName, serverIps));

            List<Player> characters = new List<Player>();
            /*
            foreach (long characterId in accountStorage.ListCharacters(session.AccountId)) {
                characters.Add(accountStorage.GetCharacter(characterId));
            }*/

            session.Send(CharacterListPacket.SetMax(4, 6));
            session.Send(CharacterListPacket.StartList());
            // Send each character data
            session.Send(CharacterListPacket.AddEntries(characters));
            session.Send(CharacterListPacket.EndList());
        }
        public override void Handle(LoginSession session, PacketReader packet)
        {
            List <Banner> banners = DatabaseManager.Banners.FindAllBanners();

            session.Send(BannerListPacket.SetBanner(banners));
            session.Send(ServerListPacket.SetServers(ServerName, ServerIPs));

            List <Player> characters = DatabaseManager.Characters.FindAllByAccountId(session.AccountId);

            Account account = DatabaseManager.Accounts.FindById(session.AccountId);

            session.Send(CharacterListPacket.SetMax(account.CharacterSlots));
            session.Send(CharacterListPacket.StartList());
            // Send each character data
            session.Send(CharacterListPacket.AddEntries(characters));
            session.Send(CharacterListPacket.EndList());
        }
        public override void Handle(LoginSession session, PacketReader packet)
        {
            byte   mode     = packet.ReadByte();
            string username = packet.ReadUnicodeString();
            string pass     = packet.ReadUnicodeString();

            Logger.Debug($"Logging in with username: '******' pass: '******'");

            // TODO: From this user/pass lookup we should be able to find the accountId
            if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(pass))
            {
                // send error / account credentials not found
            }

            session.AccountId = AccountStorage.DEFAULT_ACCOUNT_ID;

            switch (mode)
            {
            case 1:
                PacketWriter pWriter = PacketWriter.Of(SendOp.NPS_INFO);
                pWriter.WriteLong();
                pWriter.WriteUnicodeString("");

                session.Send(pWriter);
                session.Send(BannerListPacket.SetBanner());
                session.Send(ServerListPacket.SetServers(ServerName, ServerIPs));
                break;

            case 2:
                List <Player> characters = new List <Player>();
                foreach (long characterId in AccountStorage.ListCharacters(session.AccountId))
                {
                    characters.Add(AccountStorage.GetCharacter(characterId));
                }

                Logger.Debug($"Initializing login with account id: {session.AccountId}");
                session.Send(LoginResultPacket.InitLogin(session.AccountId));
                session.Send(UgcPacket.SetEndpoint("http://127.0.0.1/ws.asmx?wsdl", "http://127.0.0.1"));
                session.Send(CharacterListPacket.SetMax(4, 6));
                session.Send(CharacterListPacket.StartList());
                // Send each character data
                session.Send(CharacterListPacket.AddEntries(characters));
                session.Send(CharacterListPacket.EndList());
                break;
            }
        }
        private void SendCharacters(LoginSession session, Account account)
        {
            string serverIp      = Environment.GetEnvironmentVariable("IP");
            string webServerPort = Environment.GetEnvironmentVariable("WEB_PORT");
            string url           = $"http://{serverIp}:{webServerPort}";

            List <Player> characters = DatabaseManager.Characters.FindAllByAccountId(session.AccountId);

            Logger.Debug("Initializing login with account id: {session.AccountId}", session.AccountId);
            session.Send(LoginResultPacket.InitLogin(session.AccountId));
            session.Send(UgcPacket.SetEndpoint($"{url}/ws.asmx?wsdl", url));
            session.Send(CharacterListPacket.SetMax(account.CharacterSlots));
            session.Send(CharacterListPacket.StartList());
            // Send each character data
            session.Send(CharacterListPacket.AddEntries(characters));
            session.Send(CharacterListPacket.EndList());
        }