Forum BigDB Not able to save anything to BigDB

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

Not able to save anything to BigDB

Postby amob » August 4th, 2013, 8:10 am

All,

Need some help figuring out some basics. I used SimpleConnect to connect to my game.
And within the callback, no matter what BigDB calls I make:
I tried
Code: Select all
client.BigDB.LoadMyPlayerObject(delegate(DatabaseObject playerobject) {
                     playerobject.Set("Username", "test");
                     playerobject.Save();
                  Debug.Log ("Saved player object");
               });

or other BigDB.Load on other tables such as "users", all example type of code from the documentation.

None of them get executed. I even granted all the access rights for PlayerObject and users table. None worked.
I debugged hundreds of times...it never traced into the statement within the BigDB callback.

As a last resort, I use PlayerIO.connect() to do a full connection with a system level account.
Still the BigDB calls did not get executed.

Did I miss anything fundamental? Or it is one of those days...
amob
 
Posts: 4
Joined: April 15th, 2013, 10:02 pm

Re: Not able to save anything to BigDB

Postby kuvi » August 4th, 2013, 3:36 pm

hey man, im also in the discovery process of database retrieval and saveto.database, but it seems im one step further along than you so let me give you some help. first off, after multiple trys with the loadmyobject, i gave up on that and went for strait object.key retrieval (that is to say i skip the steps involved in building an identical client for a specific MYplayerobject search, and instead tap directly into the gameroom name/gameroom name database) anyways.....

everygame for all my players i will always have one static connect feature, that is, just connect to 'the' database for my game (in my example below i changed my actual game name from ***** to testgame-fjfce7pi5uotvmdmkafyvg, so you dont log into my own experimental server room, but im sure u understand what you need to replace in this field

//build the following into your yourDominantClass.as <public function yourDominantClass() {put it here}>
//This connects to the server (not just playerio, but playerio.yourGameRoomName and ultimately the nessesary database attached to playerio.yourGameRoomName

PlayerIO.connect(
stage,
"testgame-fjfce7pi5uotvmdmkafyvg",
"public",
name,
"",
onSuccess,
onFail)
}

public function onSuccess(client) {
_client = client //this is the part im guessing is giving you problems
}

what i want to illistrate here is that in your example you are using somethinig that caused me headacke for the longest time, your using client.bigDB.blahBlahBlah, but in my example, the client that it builds and passes along is only active during the function of the success (or fail) call. that is to say, after onSuccess finishes running "client" is lost forever, indicating to me that it was stored as a private varible instead of public. The easy workaround for this problem? at the start of your program make a var _client, dont give it a default value, during that quick blip in time where they built the client for you, make sure you save it to _client and always reference _client from here on out, in fact, with this information alone, your code may now work
kuvi
 
Posts: 11
Joined: March 29th, 2011, 12:32 am

Re: Not able to save anything to BigDB

Postby amob » August 4th, 2013, 6:20 pm

i was actually doing the call right inside the callback. So the client is definitely available in that context.
Yes, I plan to persist it and reuse the client in other scripts using what you described once I pass this step.

I think this is something more basic but I can't figure out why.

btw: I am using Unity 4.2, C#. I wonder if the Player IO library had some hiccups with the new Unity version.

Anyone experienced something similar?

My next step is to just to load the Player IO example and see if it works.
amob
 
Posts: 4
Joined: April 15th, 2013, 10:02 pm

Re: Not able to save anything to BigDB

Postby Henrik » August 5th, 2013, 5:24 pm

amob wrote:None of them get executed. I even granted all the access rights for PlayerObject and users table. None worked.
I debugged hundreds of times...it never traced into the statement within the BigDB callback.

Then you're probably getting an error, but since you don't have an error callback, you're just throwing the error message away...
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Not able to save anything to BigDB

Postby amob » August 6th, 2013, 6:09 am

The error callback was not executed either. Here is the complete snippet of the code. Do you see any issues?

Code: Select all
PlayerIO.QuickConnect.SimpleConnect(
                "gameid",
                username,
                password,
                delegate(Client client)
                {
                  client.BigDB.LoadOrCreate("users", client.ConnectUserId,
                     delegate (DatabaseObject result){
                         result.Set("username", "Charlie");
                        result.Set("age", 20);
                        result.Set("location", "London");
                        result.Save();
                        Debug.Log("saved the user record. ");
                     },
                   delegate(PlayerIOError error)
                         {
                             Debug.Log("error saving the user record. " +error.Message);
                          }
                           );            
                },
                delegate(PlayerIOError error)
                {
                    Debug.Log(error.Message);
                }
            );   
        }
amob
 
Posts: 4
Joined: April 15th, 2013, 10:02 pm

Re: Not able to save anything to BigDB

Postby Henrik » August 6th, 2013, 6:50 am

You've only added callbacks for the LoadOrCreate method. But since you just call result.Save() without any parameters, you're not setting up callbacks for the save, and have therefore no idea if the save completed or if it returned an error.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Not able to save anything to BigDB

Postby amob » August 6th, 2013, 7:36 am

I added it and still no luck. the code inside the LoadOrCreate was never executed so having the success and error call back did not seem to make a difference.

Is it possible to get some support on this? I will be happy to show it.

Code: Select all
client.BigDB.LoadOrCreate("users", client.ConnectUserId,
                     delegate (DatabaseObject result){
                        result.Set("username", "Charlie");
                        result.Set("age", 20);
                        result.Set("location", "London");
                        result.Save(delegate() {
                              Debug.Log("saved the user record. ");
                           },
                           delegate(PlayerIOError error)
                               {
                                   Debug.Log("error saving the user record. " +error.Message);
                               }
                        );
                        
                     },
                   delegate(PlayerIOError error)
                         {
                             Debug.Log("error load or create the user record. " +error.Message);
                         }
           
                  );
amob
 
Posts: 4
Joined: April 15th, 2013, 10:02 pm


Return to BigDB