예제 #1
0
        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;
            }
        }
        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());
        }
예제 #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 = AccountStorage.DEFAULT_ACCOUNT;
            }
            else
            {
                session.AccountId = AccountStorage.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;
            }
        }