Store user related data during smartfox login

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

Moderators: Lapo, Bax

Devops
Posts: 23
Joined: 27 May 2020, 15:23

Store user related data during smartfox login

Postby Devops » 19 Jun 2020, 05:30

Client side will be sending some custom data during smartfox login.

And in the extension, I want to store this data mapped to this user in the memory.
The problem here is in order to map it to this user, I would need their userId or atleast their SFSUserObject in login request in extension.
I guess the userId and all will be decided only after the login is successful.


Is there any way to retrieve the userId which will be assigned to the user in the login request itself, in smartfox extension?
Or any other way to deal with this?

I cannot use USER_LOGIN_ZONE because at this time I won't be having access to the custom data(this is passed to login request)
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Store user related data during smartfox login

Postby Lapo » 19 Jun 2020, 07:50

Hi,
at the time of the Login request the User object does not exist yet, but the client is represented with a Session object which is passed to the developer via the SFSEvent.LOGIN event.

You can store any object/data in the Session via Session.getProperty() / setProperty(). When the User object is created after a successful login it will expose a getSession() method that returns the Session object previously used.

In other words, after login is complete you can access your data from the Session object via:

Code: Select all

String customProp = (String) userObj.getSession().getProperty("someName");


Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 78 guests