Server User data storage

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
moccha
Posts: 112
Joined: 13 Feb 2014, 16:09

Server User data storage

Postby moccha » 25 May 2021, 20:30

Hello,

In the login phase once the client joins the zone, the User has their SFSUserVariables set from the session properties. Is it better to store each one individually, such as:

Code: Select all

UserVariable name = new SFSUserVariable("name",user.getSession().getProperty("n"));
UserVariable money = new SFSUserVariable("money",user.getSession().getProperty("m"));
...

or is it better to lump everything together into a single UserVar and then access it accordingly:

Code: Select all

ISFSObject sfso = new SFSObject();
sfso.putUtfString("name", user.getSession().getProperty("n").toString());
sfso.putInt("name", (Integer) user.getSession().getProperty("m"));
...
UserVariable data = new SFSUserVariable("data", sfso);


Are there pros and cons to both, or is one preferable?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server User data storage

Postby Lapo » 26 May 2021, 09:24

Hi,
with separate variables updates are smaller, since only what changes gets transmitted.
Lumping all variables in an SFSObject can be ok but every update will transmit the whole SFSObject to everyone.

Also the client will not know exactly what changed because it just receives one SFSObject. With separate variables the client side API will tell you which variable was affected by the UserVariableUpdate event.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
moccha
Posts: 112
Joined: 13 Feb 2014, 16:09

Re: Server User data storage

Postby moccha » 26 May 2021, 13:30

Okay, separate user vars sounds like a good plan then. Is there an upper limit you would suggest to stay within? I'm guessing there will probably be at least 30 different SFSUserVariables per user, but it may grow. Any advice you have is welcome.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server User data storage

Postby Lapo » 27 May 2021, 14:26

I don't have any specific advice on this, other than what I poster earlier :)

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 50 guests