Hi Lapo,
I am trying to achieve passing extra parameters when user logged in on server side, and do something with these parameters when this user disconnects. I've set up login handler, zone join handler and disconnection handler. I successfully grab the parameter inside login handler. The problem is I tried to set User Variables but the user, by that time, is not ready. That means I got null if I try to get the "User" parameter. Then I tried to do so in zone join handler. Unfortunately, even though the user will be ready then, I lost access to login parameters.
What's your suggestions on this? How can I store user specific data inside join handler and grab it inside disconnection handler? Thank you in advance!
Set User Variables Upon Server Side Login
Re: Set User Variables Upon Server Side Login
Hi,
you're correct, the User object does not exist yet when you log in and it is created and passed in the USER_JOIN_ZONE event.
However you can store any parameter in the Session with:
And read them back in the JOIN event with:
If these parameters are supposed to be used to create UserVariables you can already prepare the SFSUserVariable object in the LOGIN event and store that in the Session properties.
Example:
You get the idea.
Cheers
you're correct, the User object does not exist yet when you log in and it is created and passed in the USER_JOIN_ZONE event.
However you can store any parameter in the Session with:
Code: Select all
session.setProperty("name", value);And read them back in the JOIN event with:
Code: Select all
var value = (Integer) user.getSession().getProperty("name");If these parameters are supposed to be used to create UserVariables you can already prepare the SFSUserVariable object in the LOGIN event and store that in the Session properties.
Example:
Code: Select all
session.setProperty("myVar", new SFSUserVariable("name", value);You get the idea.
Cheers