Forum BigDB Calling bigDB when UserLeft function is called

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

Calling bigDB when UserLeft function is called

Postby adahy » September 27th, 2015, 6:06 pm

Hello. I want to update bigDB when a player leaves but when I try to call bigDB in the public override void UserLeft(Player player) { } function I get an error.

The dev server status board reads:
Trying last loaded dll
- error: Could not find any Player.IO room types [RoomType(...)] in the dll.

When I try to load the dll an error message pops that reads:
Sorry, this is not a valid game dll. Valid game dlls must have a class that inherits from PlayerIO......

here is the code that is making the error. When I comment out the BigDB load it works fine. What am I doing wrong?? Thank you for your help!!!

Code: Select all
public override void UserLeft(Player player) {
            //show player in bigDB as logged off
        PlayerIO.BigDB.Load("OnlinePlayers", player.name, delegate (DatabaseObject result) {
          result.Set("Logged On", false);
        }, delegate (PlayerIOError error) {
                //Handle error here...
         });
}
adahy
 
Posts: 16
Joined: April 13th, 2010, 9:14 am

Re: Calling bigDB when UserLeft function is called

Postby adahy » September 27th, 2015, 6:35 pm

Interesting..... when I use this code it seems to work just fine.. What am I doing wrong?
Code: Select all
   public override void UserLeft(Player player) {
            //show player in bigDB as logged off
           // signout();
            PlayerIO.BigDB.LoadOrCreate("OnlinePlayers", player.name,
                      delegate (DatabaseObject result) {
                          if (!result.Contains("username"))
                          {
                              result.Set("Name", player.name);
                              result.Set("Logged On", false);
                          }
                          result.Set("Logged On", false);
                          result.Save();
                      }
                      );

      }
adahy
 
Posts: 16
Joined: April 13th, 2010, 9:14 am

Re: Calling bigDB when UserLeft function is called

Postby Guillaume » September 27th, 2015, 9:29 pm

I don't think that you can rely to UserLeft method to do any critical operation, as if your last player leave the room, the room will be closed, and your code may be not fired for this user.

It's stated in the documentation here: https://gamesnet.yahoo.net/documentatio ... e#UserLeft

And some hint of Henrik, posted in 2013: viewtopic.php?f=4&t=34845&p=46172&hilit=room+closed&sid=146f72337b211696090cf514d0c6a174#p46172

In my opinion, its safer to use a "Timer" flag, to know who is connected, as someone who is disconnected will not update his Timer data anymore.
Guillaume
 
Posts: 277
Joined: March 28th, 2014, 1:59 am
Location: France


Return to BigDB



cron