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.