public static void HandleClientToken(NetworkClient Client, ProcessedPacket P)
        {
            ClientToken Token = new ClientToken();
            Token.ClientIP = P.ReadPascalString();
            Token.CharacterGUID = P.ReadPascalString();
            Token.Token = P.ReadPascalString();

            NetworkFacade.TransferringClients.AddItem(Token);
        }
        public static void HandleClientToken(NetworkClient Client, ProcessedPacket P)
        {
            try
            {
                ClientToken Token = new ClientToken();
                Token.AccountID = P.ReadInt32();
                Token.ClientIP = P.ReadPascalString();
                Token.CharacterGUID = P.ReadPascalString();
                Token.Token = P.ReadPascalString();

                NetworkFacade.TransferringClients.AddItem(Token);
            }
            catch (Exception E)
            {
                Logger.LogDebug("Exception in HandleClientToken: " + E.ToString());
            }
        }
        /// <summary>
        /// A client wanted to transfer to this server, so a token was generated by the login server.
        /// </summary>
        public static void HandleClientToken(NetworkClient Client, ProcessedPacket P)
        {
            try
            {
                ClientToken Token = new ClientToken();
				byte CharacterCreate = (byte)P.ReadByte();
                Token.AccountID = P.ReadInt32();
                Token.ClientIP = P.ReadString();
				int ClientPort = P.ReadInt32();
                Token.CharacterGUID = P.ReadString();
                Token.Token = P.ReadString();

				PacketStream PlayerOnlinePacket = new PacketStream(0x67, 0);
				PlayerOnlinePacket.WriteHeader();
				PlayerOnlinePacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1 +
					Token.Token.Length + 1 + Token.ClientIP.Length + 1 + 4));

				if (CharacterCreate == 0)
				{
					if (NetworkFacade.CurrentSession.GetPlayer(Token.CharacterGUID) == null)
					{
						NetworkClient WaitingClient = NetworkFacade.NetworkListener.GetClient(Token.ClientIP, ClientPort);
						//Uh-oh, someone's waiting for their token!
						if(WaitingClient != null)
						{
							PacketStream SuccessPacket = new PacketStream((byte)PacketType.CITY_TOKEN, 0);
							SuccessPacket.WriteByte((byte)CityTransferStatus.Success);
							WaitingClient.SendEncrypted((byte)PacketType.CITY_TOKEN, SuccessPacket.ToArray());
						}

						PlayerOnlinePacket.WriteByte(0x01);
						PlayerOnlinePacket.WriteString(Token.Token);
						PlayerOnlinePacket.WriteString(Token.ClientIP);
						PlayerOnlinePacket.WriteInt32(ClientPort);

						lock (NetworkFacade.TransferringClients)
						{
							if (!NetworkFacade.TransferringClients.Contains(Token))
								NetworkFacade.TransferringClients.Add(Token);
						}

						Client.Send(PlayerOnlinePacket.ToArray());
					}
					else
					{
						PlayerOnlinePacket.WriteByte(0x02);
						PlayerOnlinePacket.WriteString(Token.Token);
						PlayerOnlinePacket.WriteString(Token.ClientIP);
						PlayerOnlinePacket.WriteInt32(ClientPort);

						Client.Send(PlayerOnlinePacket.ToArray());
					}
				}
				else
				{
					NetworkClient WaitingClient = NetworkFacade.NetworkListener.GetClient(Token.ClientIP, ClientPort);
					//Uh-oh, someone's waiting for their token!
					if (WaitingClient != null)
					{
						PacketStream SuccessPacket = new PacketStream((byte)PacketType.CITY_TOKEN, 0);
						SuccessPacket.WriteByte((byte)CityTransferStatus.Success);
						WaitingClient.SendEncrypted((byte)PacketType.CITY_TOKEN, SuccessPacket.ToArray());
					}

					if (!NetworkFacade.TransferringClients.Contains(Token))
						NetworkFacade.TransferringClients.Add(Token);
				}
            }
            catch (Exception E)
            {
                Logger.LogDebug("Exception in HandleClientToken: " + E.ToString());
            }
        }
        /// <summary>
        /// Received client token.
        /// </summary>
        public static void HandleCityToken(NetworkClient Client, ProcessedPacket P)
        {
            try
            {
                //bool ClientAuthenticated = false;
                ClientToken TokenToRemove = new ClientToken();

                using (DataAccess db = DataAccess.Get())
                {
                    string Token = P.ReadString();
                    ClientToken Tok;

                    if (Token == string.Empty)
                        return;

                    Tok = NetworkFacade.GetClientToken(new Guid(Token));

                    if (Tok != null)
                    {
                        //ClientAuthenticated = true;
                        TokenToRemove = Tok;

                        Character Char = db.Characters.GetForCharacterGUID(new Guid(Tok.CharacterGUID));
                        if (Char != null)
                        {
                            NetworkFacade.CurrentSession.AddPlayer(Client, Char);

                            PacketStream SuccessPacket = new PacketStream((byte)PacketType.CITY_TOKEN, 0);
                            SuccessPacket.WriteByte((byte)CityTransferStatus.Success);

                            House[] Houses = NetworkFacade.CurrentSession.GetHousesInSession();
                            SuccessPacket.WriteUInt16((ushort)Houses.Length);

                            //Ho, ho, ho...
                            foreach (House Ho in Houses)
                            {
                                SuccessPacket.WriteInt32(Ho.HouseID);
                                SuccessPacket.WriteString(Ho.Name);
                                SuccessPacket.WriteUInt16((ushort)Ho.X);
                                SuccessPacket.WriteUInt16((ushort)Ho.Y);
                                SuccessPacket.WriteByte((byte)Ho.Flags); //Might have to save this as unsigned in DB?
                                SuccessPacket.WriteInt32(Ho.Cost);
                            }

                            SuccessPacket.WriteInt32(Char.Money);

                            Client.SendEncrypted((byte)PacketType.CITY_TOKEN, SuccessPacket.ToArray());
                        }
                        /*else
                        {
                            ClientAuthenticated = false;
                            break;
                        }*/
                    }

                    NetworkFacade.TransferringClients.TryRemove(out TokenToRemove);

                    //This is not really valid anymore, because if the token doesn't exist yet,
                    //the client will now receive it when it arrives - see LoginPacketHandlers.cs
                    // - HandleClientToken()
                    /*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());
                Debug.WriteLine("Exception in HandleCityToken: " + E.ToString());

                PacketStream ErrorPacket = new PacketStream((byte)PacketType.CITY_TOKEN, 0);
                ErrorPacket.WriteByte((byte)CityTransferStatus.GeneralError);
                Client.SendEncrypted((byte)PacketType.CITY_TOKEN, ErrorPacket.ToArray());
            }
        }