Forum BigDB Accessing variable in callback.

Discussion and help relating to the PlayerIO database solution, BigDB.

Accessing variable in callback.

Postby Raimonds » June 1st, 2013, 10:46 am

Hello.
I guess it is more like C# question and even multiplayer, but it is related to the BigDB. I have a code.
Code: Select all
public override void GotMessage(Player player, Message message)
        {
            base.GotMessage(player, message); //MESSAGE object AVAIBLABLE HERE
            switch (message.Type)
            {
                case "updateLevel":
                    {
                        PlayerIO.BigDB.Load("levels", message.GetString(5), delegate(DatabaseObject save)
                        {
                            save.Set("levelData", message.GetString(0)); //HERE I GET NULL EXCEPTION
                            save.Set("levelHeight", message.GetUInt(2));
                            save.Set("levelLenght", message.GetUInt(1));
                            save.Set("edited_at", time);
                            save.Set("isPublic", message.GetBoolean(3));
                            save.Set("name", message.GetString(4));
                            save.Save();
                        });
                        break;
                    }
            }


The problem is, I can not access message variable in the Load callback. As I am not that familiar with C#, I have no clue how to solve this. Any help would be awesome. Thank you. (:
Raimonds
 
Posts: 3
Joined: May 26th, 2012, 3:52 pm

Re: Accessing variable in callback.

Postby Henrik » June 1st, 2013, 6:39 pm

That should work. Have you tested and made sure that it is message that is null, and not simply GetString(0) that fails?
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Accessing variable in callback.

Postby Raimonds » June 1st, 2013, 7:18 pm

Oh right. There were other things causing that error.

Thank you, and sorry. You can delete this. [:
Raimonds
 
Posts: 3
Joined: May 26th, 2012, 3:52 pm


Return to BigDB



cron