In the example:
https://smartfoxserver.com/blog/custom- ... -database/
In the LoginEventHandler, you store the database id into the session property.
Then in the ZoneJoinEventHandler, you have code that moves the session property into a hidden user variable:
--- code from the example
// dbid is a hidden UserVariable, available only server side
UserVariable uv_dbId = new SFSUserVariable("dbid", theUser.getSession().getProperty(DBLogin.DATABASE_ID));
----
Why move the dbid into a hidden user variable instead of keeping it in the user's session property? What are the advantages/disadvantages? I noticed in my experiments that even in my room's extension, I'm still able the access the user's session to get dbid, so why bother moving it into user variable?
User session property vs user variable
Re: User session property vs user variable
Hi,
essentially it is just for convenience, since you're probably going to use multiple UserVariables for each client.
It's about keeping the User's data in one place. But you can do otherwise (i.e. use Properties) and it will be fine as well.
Cheers
essentially it is just for convenience, since you're probably going to use multiple UserVariables for each client.
It's about keeping the User's data in one place. But you can do otherwise (i.e. use Properties) and it will be fine as well.
Cheers
Who is online
Users browsing this forum: No registered users and 99 guests