Forum QuickConnect PlayerObject not created

Discussion and help relating to PlayerIO's QuickConnect feature, including Facebook Connect and Kongregate Connect.

PlayerObject not created

Postby sebas77 » August 20th, 2013, 6:13 pm

Hi,

this is a rare issue, happened only once so far to one of our new users.

We noticed this behaviour: the user was able to register a new user through QuickConnect, the user is present in the QuickConnect table, however the playerObject was not created and the web service room was not able to load one.

How could this happen? Should I put defensive code in our web services to create a player object is one is not created?
sebas77
Paid Member
 
Posts: 137
Joined: June 25th, 2013, 12:09 pm

Re: PlayerObject not created

Postby sebas77 » August 22nd, 2013, 10:43 am

yes it happens...we cannot assume that the playerobject is created on userjoined after registration with quick connect
sebas77
Paid Member
 
Posts: 137
Joined: June 25th, 2013, 12:09 pm

Re: PlayerObject not created

Postby sebas77 » August 22nd, 2013, 12:39 pm

ok I understood on my own that the playerobject is not created during the registration phase, but the first time one user joins a room.

Dangerous design, since the joining of the room could fail and the client API allows to load the PlayerObject directly without creating it if it does not exist.

the client version loadMyPlayerObject should create the object if it does not exist, but I understand that there could be permission issues.
Last edited by sebas77 on August 23rd, 2013, 10:15 am, edited 1 time in total.
sebas77
Paid Member
 
Posts: 137
Joined: June 25th, 2013, 12:09 pm

Re: PlayerObject not created

Postby Henrik » August 23rd, 2013, 4:05 am

When you use loadMyPlayerObject in a client, or the PlayerObject property in server-side code, you will always get a DatabaseObject back that you can put data in, but nothing is saved to BigDB until you call Save() on it once.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: PlayerObject not created

Postby renaud974 » September 16th, 2013, 2:42 pm

With this code, the frst time a user connects to a room with quickconnect , after he has registered, it will create an entry inside playerobjects for him, and an entry inside the table users also(created manually in admin panel).

This happens once.

Thanks to Henrik's answer, and the reference doc http://playerio.com/documentation/refer ... rary.bigdb

I was expecting the playerobject that didnt exist to be null, but it is not null, it is just an empty object that you must write data into as Henrik said.

Code: Select all
            PlayerIO.BigDB.LoadOrCreate("users", player.ConnectUserId,
                delegate(DatabaseObject result)
                {
                    if (!result.Contains("name"))
                    {
                        //Empty object, initialize it
                        result.Set("name", player.ConnectUserId);
                        result.Set("gold", 20);
                        result.Set("exp", 0);
                        result.Set("age", 42);
                        //here you can add anything you want.

                        //filling the playerobject for this player
                        player.GetPlayerObject(delegate(DatabaseObject o)
                        {
                            o.Set("name", player.ConnectUserId);
                            //here you can add anything you want.
                            o.Save();
                        });
                    }
                   
                    //the object is created or loaded, you can do stuff with it before saving
                    result.Save();
                }
            );


Also i noticed that you can put any property you want in any object of any table without restriction.
2 objects of the same table can have different properties.

Unlike SQL databases where you need to fill the corresponding fields properly.

With BigDB this is the first time i use a NoSQL database, and it is dead simple.
renaud974
 
Posts: 4
Joined: September 13th, 2013, 7:48 pm

Re: PlayerObject not created

Postby Benjaminsen » September 16th, 2013, 8:58 pm

When loading a PlayerObject you should always expect to get at-least an empty object back. If that is not the case, I would very much like to hear more about how you where able to get the system into that error state.

Even more so, if you have a way to replicate this behavior we will have that ting fixed ASAP :)
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: PlayerObject not created

Postby AdamW » September 17th, 2013, 8:55 pm

Hello all,

Adding myself to the thread to get notified if we have steps to replicate.

Thanks,
Adam
Yahoo Games - Forums Moderator
User avatar
AdamW
 
Posts: 18
Joined: May 30th, 2013, 9:03 pm


Return to QuickConnect