Advertisement

Login confusion

Started by December 06, 2014 08:10 PM
0 comments, last by hplus0603 9 years, 11 months ago

Given the following:


        /// <summary>
        /// Received client token.
        /// </summary>
        public static void HandleCityToken(NetworkClient Client, ProcessedPacket P)
        {
            try
            {
                bool ClientAuthenticated = false;
 
                using (DataAccess db = DataAccess.Get())
                {
                    string Token = P.ReadString();
 
                    foreach (ClientToken Tok in NetworkFacade.TransferringClients)
                    {
                        //Token matched, so client must have logged in through login server first.
                        if (Tok.Token.Equals(Token, StringComparison.InvariantCultureIgnoreCase))
                        {
                            ClientAuthenticated = true;
 
                            Character Char = db.Characters.GetForCharacterGUID(new Guid(Tok.CharacterGUID));
                            if (Char != null)
                            {
                                lock(NetworkFacade.CurrentSession)
                                    NetworkFacade.CurrentSession.AddPlayer(Client, Char);
 
                                PacketStream SuccessPacket = new PacketStream((byte)PacketType.CITY_TOKEN, 0);
                                SuccessPacket.WriteByte((byte)CityTransferStatus.Success);
                                Client.SendEncrypted((byte)PacketType.CITY_TOKEN, SuccessPacket.ToArray());
 
                                break;
                            }
                            else
                            {
                                ClientAuthenticated = false;
                                break;
                            }
                        }
                    }
 
                    if (!ClientAuthenticated)
                    {
                        PacketStream ErrorPacket = new PacketStream((byte)PacketType.CITY_TOKEN, 0);
                        ErrorPacket.WriteByte((byte)CityTransferStatus.GeneralError);
                        Client.SendEncrypted((byte)PacketType.CITY_TOKEN, ErrorPacket.ToArray());
                    }
                }
            }
            catch (Exception E)
            {
                Logger.LogDebug("Exception in HandleCityToken: " + E.ToString());
            }
        }
 
 
(...)
 
        private Dictionary<NetworkClient, Character> m_PlayingCharacters = new Dictionary<NetworkClient, Character>();
 
        /// <summary>
        /// Adds a player to the current session.
        /// </summary>
        /// <param name="Client">The player's client.</param>
        /// <param name="Char">The player's character.</param>
        public void AddPlayer(NetworkClient Client, Character Char)
        {
            lock (m_PlayingCharacters)
            {
                foreach (KeyValuePair<NetworkClient, Character> KVP in m_PlayingCharacters)
                {
                    ClientPacketSenders.SendPlayerJoinSession(KVP.Key, Char);
                    //Send a bunch of these in reverse (to the player joining the session).
                    ClientPacketSenders.SendPlayerJoinSession(Client, KVP.Value);
                }
 
                m_PlayingCharacters.Add(Client, Char);
            }
        }

why do BOTH players receive information about the other (or self?) when I log on using the same account, but NONE receive any information when I log in using two different accounts o_O

The answer should be blindingly obvious, I can't see it.

If you set a breakpoint when the second player logs in, and step through the code line by line to see what it actually sends (and compare to what you'd expect it to send,) what do you find?
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement