Forum BigDB Load Player and Register Using Server Code

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

Load Player and Register Using Server Code

Postby prsolucoes » October 31st, 2012, 5:35 am

Hi,

There is any possible way to register a player using quick connect on serverside?

There is any possible way to load a registered player using their username/password of quick connect on serverside?

Im asking it because my game is doing the process:

1 - Register on SimpleRegister by the Flash application
2 - Login with SimpleConnect
3 - If success on #2, send username to server (from Flash - Actionscript):

Code: Select all
MessageManager.getInstance().getConnection().send("LOGIN", GameObjects.profile.accountUsername);


3 - The server receive login message and try load or create the user is username doesn't exists:

LOAD CODE

Code: Select all
      
// This method is called when a player leaves the game
public override void UserLeft (Player player)
{
   player.Save ();
}

// This method is called when a player sends a message into the server code
public override void GotMessage (Player player, Message message)
{
   switch (message.Type.ToUpper ()) {
   case "LOGIN":
      {
         player.CreateOrLoad (message.GetString (0)); // get username here :)
         player.Send ("LOGIN_OK", player.Id);
         break;
      }

   case "PROFILE":
      {
         player.Send ("PROFILE", player.Id, player.Username, player.ExperiencePoints, player.CashPoints); // send some profile data - there is a way to pass all in one object?
         break;
      }
   }
}


PLAYER CLASS

Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PlayerIO.GameLibrary;

namespace Engine
{
   public class Player : BasePlayer
   {
      public String Username;
      public int ExperiencePoints;
      public int CashPoints;

      public Player ()
      {
         Username = null;
         ExperiencePoints = 0;
         CashPoints = 0;
      }

      public void CreateOrLoad (String Username)
      {
         Boolean exist = PlayerObject.Contains ("Username");

         if (!exist) {
            Create (Username);
         }

         Load ();
      }

      void Create (String Username)
      {
         PlayerObject.Set ("Username", Username);
         Save ();
      }

      public void Load ()
      {
         Username = PlayerObject.GetString ("Username");
         ExperiencePoints = PlayerObject.Contains ("ExperiencePoints") ? PlayerObject.GetInt ("ExperiencePoints") : 0;
         CashPoints = PlayerObject.Contains ("CashPoints") ? PlayerObject.GetInt ("CashPoints") : 0;
      }
      
      public void Save ()
      {
         PlayerObject.Set ("Username", Username);
         PlayerObject.Set ("ExperiencePoints", ExperiencePoints);
         PlayerObject.Set ("CashPoints", CashPoints);

         PlayerObject.Save ();
      }
   }
}


This is the best method? What the best method to do this process?

Ty.
prsolucoes
 
Posts: 47
Joined: March 18th, 2010, 3:20 pm

Re: Load Player and Register Using Server Code

Postby Benjaminsen » October 31st, 2012, 1:13 pm

There is no way to use QuickConnect on the server, however it should not be needed, basically you should never need to send the username, nor the password to your servers as the user has already authenticated towards player.io and thus the server.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Load Player and Register Using Server Code

Postby prsolucoes » October 31st, 2012, 2:17 pm

But i need get on server the player username To send To others. How i will do it if i dont have acess To player register data?
prsolucoes
 
Posts: 47
Joined: March 18th, 2010, 3:20 pm

Re: Load Player and Register Using Server Code

Postby Henrik » October 31st, 2012, 2:23 pm

When you connect to the multiplayer server, send it through Join data, or a Message. You have the username on the client already, right?
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Load Player and Register Using Server Code

Postby Benjaminsen » October 31st, 2012, 2:28 pm

prsolucoes wrote:But i need get on server the player username To send To others. How i will do it if i dont have acess To player register data?


For SimpleConnect the username of the player is is part of the connectUserId
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Load Player and Register Using Server Code

Postby prsolucoes » October 31st, 2012, 2:46 pm

But This method is not decent :(

I will use it so :(
prsolucoes
 
Posts: 47
Joined: March 18th, 2010, 3:20 pm

Re: Load Player and Register Using Server Code

Postby Benjaminsen » October 31st, 2012, 3:19 pm

I suggest you totally disconnect usernames from your authentication. Let users login with email / password then have a custom username migration system.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to BigDB