Exemplo n.º 1
0
        public static void HandleRealmList(WorldSession session, ClientRealmList realmList)
        {
            var serverRealmList = new ServerRealmList
            {
                Messages = ServerManager.ServerMessages
                           .Select(m => new NetworkMessage
                {
                    Index    = m.Index,
                    Messages = m.Messages
                })
                           .ToList()
            };

            foreach (ServerInfo server in ServerManager.Servers)
            {
                serverRealmList.Realms.Add(new ServerRealmList.RealmInfo
                {
                    RealmId          = server.Model.Id,
                    RealmName        = server.Model.Name,
                    Type             = (RealmType)server.Model.Type,
                    Status           = RealmStatus.Up,
                    Population       = RealmPopulation.Low,
                    Unknown8         = new byte[16],
                    AccountRealmInfo = new ServerRealmList.RealmInfo.AccountRealmData
                    {
                        RealmId = server.Model.Id
                    }
                });
            }

            session.EnqueueMessageEncrypted(serverRealmList);
        }
Exemplo n.º 2
0
        public static void HandleRealmList(WorldSession session, ClientRealmList realmList)
        {
            var serverRealmList = new ServerRealmList();

            foreach (ServerManager.ServerInfo server in ServerManager.Servers)
            {
                // TODO: finish this...
                serverRealmList.Realms.Add(new ServerRealmList.RealmInfo
                {
                    Unknown0   = 1,
                    Realm      = server.Model.Name,
                    Type       = (RealmType)server.Model.Type,
                    Status     = RealmStatus.Up,
                    Population = RealmPopulation.Low
                });
            }

            session.EnqueueMessageEncrypted(serverRealmList);
        }
Exemplo n.º 3
0
        private static void SendRealmList(LobbySession session)
        {
            ReadOnlyCollection <RealmInfo> realmInfo = AssetManager.RealmInfoStore;

            ServerRealmList realmList = new ServerRealmList {
                Sequence = session.Sequence
            };

            for (ushort i = 0; i < realmInfo.Count; i++)
            {
                // client expects no more than 6 realms per chunk
                if (i % ServerRealmList.MaxRealmsPerPacket == 0)
                {
                    // flush previous chunk
                    if (i != 0)
                    {
                        session.Send(realmList);
                        realmList.Realms.Clear();
                    }

                    realmList.Offset = i;
                    realmList.Final  = (ushort)(realmInfo.Count - i < ServerRealmList.MaxRealmsPerPacket ? 1 : 0);
                }

                RealmInfo realm = realmInfo[i];
                realmList.Realms.Add(new ServerRealmList.RealmInfo
                {
                    Id       = realm.Id,
                    Position = i,
                    Name     = realm.Name,
                    Flags    = realm.Flags
                });

                // flush final chunk
                if (i == realmInfo.Count - 1)
                {
                    session.Send(realmList);
                }
            }
        }
Exemplo n.º 4
0
        protected override async Task HandlePacket(byte[] packet)
        {
            this.LogPacket(packet);
            switch (this.state)
            {
            case ClientState.Init:
                this.state = ClientState.LogonChallenge;
                this.Log("-> ClientLogonChallenge");
                await new ClientLogonChallenge(packet, this).Execute();
                this.Log("<- ServerLogonChallenge");
                break;

            case ClientState.LogonChallenge:
                this.state = ClientState.LogonProof;
                this.Log("-> ClientLogonProof");
                var success = await new ClientLogonProof(packet, this).Execute();
                this.Log($"<- ServerLogonProof {(success ? "successful" : "failed")}");
                if (success)
                {
                    this.state = ClientState.Authenticated;
                    this.Log("-- Client authenticated");
                }
                else
                {
                    this.state       = ClientState.Disconnected;
                    this.isConnected = false;
                    this.Log("-- Client authentication failed");
                }
                break;

            case ClientState.Authenticated:
                DataStore.Users.TryAdd(this.SRP.I, new User(this.SRP));
                this.Log("<- Realmlist sent");
                await ServerRealmList.Send(this);

                break;
            }
        }