Trouble after splitting the AuthServer & GameServer

02/03/2011 14:29 _DreadNought_#1
Hey guys,

I'm back doing some coding for the first time this year and I cannot seem to fix a problem I had a while back after splitting my GameServer & AuthServer.

In my AuthServer I currently have a dictionary called AwaitingPool and it will store a uint(Forward Packet Identifier) and also store a reference to the user's account. Looks abit like
Code:
public static Dictionary<uint, Database.AccountTable> AwaitingPool = new Dictionary<uint, Database.AccountTable>();
My GameServer needs to confirm upon confirmation of login that the Key exists in the dictionary and also to pull out the Account.

What the odd thing is, is that I try to pull out the key and my GameServer claims the Dictionary is absolutely empty, I do a test with both consoles making a command on both, to get the count on the dictionary after I try to login, AuthServer claims my key and account is in there while at the same time my GameServer claims it is empty.
AuthServer is referenced by the GameServer as a project.

Anybody know what's going on?
02/03/2011 20:31 12tails#2
lol... easy to split it...

make something more simple... make an unique id for accounts... and them check it's acc & pw into acc server...

send the login token using the acc uid and get the account into gameserver using this id... and just continue the login sequence ... should work perfectly...
02/03/2011 21:04 pro4never#3
Sounds to me like when you validate the login you are not sending information to the game server so that it can add it to its login clients dict.

Setup a simple socket to communicate between the two would be the simplest way.
02/03/2011 22:35 12tails#4
//EDIT: Like pro4ever said.... check if there are connection between the both programs.... other else you'll not get it working... them try this:

"AuthServer is referenced by the GameServer as a project"

let me show how i've done it...

there are two projects ... one auth and one game... btw none of them are referenced to each other... so, how do i get the login token??

like this:

Code:
                AuthState player = arg2.connector as AuthState;
                player.Cryptography.Decrypt(arg1);
                player.Info = new Authentication();
                player.Info.Deserialize(arg1, player.GeneratedKey);
                player.Account = new AccountTable(player.Info.Username);
                Console.WriteLine("[Auth-Socket] Incomming connection to " + player.Account.Username + " and password " + player.Account.Password);
                Forward Fw = new Forward();
                if (player.Account.Password.Equals(player.Info.Password))
                {
                    if (player.Account.State == AccountTable.AccountState.Banned)
                        Fw.Type = Forward.ForwardType.Banned;
                    else
                        Fw.Type = Forward.ForwardType.Ready;
                }
                else
                {
                    Fw.Type = Forward.ForwardType.InvalidInfo;
                }
                if (Fw.Type != Forward.ForwardType.InvalidInfo)
                {
                    Fw.Identifier = player.Account.AccountID;
                }
                Fw.IP = "127.0.0.1";//IP Adress
                Fw.Port = 5816;//GameServer port...
                player.Send(Fw);
and them at game server we do:
Code:
        static void AppendConnect(Connect appendConnect, Client.GameState client)
        {
            Database.AccountTable Account = new AccountTable(appendConnect.Identifier);
            if (Account != null)
            {
                client.Account = Account;
                string Message = "NEW_ROLE";
                if (client.Account.EntityID != 0)
                    Message = "ANSWER_OK";
                if (Account.State == Database.AccountTable.AccountState.Banned)
                    Message = "The account: " + Account.Username + " has been banned.";
                client.Send(new Message(Message, "ALLUSERS", System.Drawing.Color.Orange, GamePackets.Message.Dialog));
                if (Message == "ANSWER_OK")
                {
                    if (ServerBase.Kernel.GamePool.ContainsKey(client.Account.EntityID))
                    {
                        Client.GameState aClient = null;
                        if (ServerBase.Kernel.GamePool.TryGetValue(client.Account.EntityID, out aClient))
                        {
                            try
                            {
                                if (aClient != null)
                                {
                                    aClient.Disconnect();
                                }
                            }
                            catch { ServerBase.Kernel.GamePool.Remove(client.Account.EntityID); }
                        }
                    }
                    Database.EntityTable.LoadEntity(client);
                    ServerBase.Kernel.GamePool.Add(client.Entity.UID, client);
                    if (!ServerBase.Kernel.WasInGamePool.ContainsKey(client.Account.EntityID))
                        ServerBase.Kernel.WasInGamePool.Add(client.Entity.UID, client);
                    client.Send(new GamePackets.CharacterInfo(client));
                    string IP = client.Socket.RemoteEndPoint.ToString().Split(':')[0].ToString();
                    client.Account.IP = IP;
                    client.Account.Save();
                    Database.EntityTable.UpdateOnlineStatus(client, true);
                    Console.WriteLine("Successful Connection ([" + client.Account.IP + "] [" + client.Account.Username + "])");
                    client.Action = 2;
                }
            }
            else { client.Disconnect(); }
        }
Hope it helped...

Regards... Leo

PLEASE DO NOT COPY AND PASTE THIS... IT SHOULD NOT WORK ONLY DOING THIS... AND YOU WILL NOT LEARN BY DOING THAT!
02/04/2011 16:19 _DreadNought_#5
Yah ^ I was currently doing that. I uhm.. made mine a little more complicated then yours above to support for new accounts made by the register code and the Unique ID is created on AuthServer.

I have it working now anyway, so Thanks :)
I didn't copy and paste that, even if I tried your source is different from mine.