os uses id when sfs uses name?

Post here your questions about the OpenSpace 1.x or notify bugs and suggestions.

Moderators: Lapo, Bax

sstark
Posts: 77
Joined: 21 Nov 2008, 16:06

os uses id when sfs uses name?

Postby sstark » 21 Jul 2009, 16:27

in the openspace events it passes the user's id in the params, but in the smart fox events it's the username. The id is actually not useful to me, and I will have to record the named id in an indexed array so that my other systems know the correct user. for example, MySQL user id != SFS user id.

Would we be able to either switch or add the username into the params for openspace events, and unify this?
User avatar
Bax
Site Admin
Posts: 4517
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 23 Jul 2009, 11:52

Can you make an example where you need the username instead of the id in an OpenSpace event?
Paolo Bax
The SmartFoxServer Team
sstark
Posts: 77
Joined: 21 Nov 2008, 16:06

Postby sstark » 23 Jul 2009, 15:39

Sure can!

Our users are based on a mysql table, registration / session is done via RoR, and user for other areas of the website.

This means that our system NEEDS to be user name based. The sfs id is actually worthless to almost all of my code, it needs the username. The user is the key in all my hash's... including my custom avatar creator.

This is currently an issue while applying environment effects on the avatars.

My current workaround it to keep a sfs id -> username hash around, but that's generated on a few bizarre avatar events to collect the right information without a custom extension just to poll sfs and collect username information.
User avatar
Bax
Site Admin
Posts: 4517
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 27 Jul 2009, 08:53

Why don't you just retrive the User object from the current Room?

Code: Select all

var room:Room = smartFox.getActiveRoom() // smartFox is your SmartFoxClient instance
var user:User = room.getUser(id) // id is the user id passed by the OpenSpace events you are listening to
var username:String = user.getName()

Hope this helps.
Paolo Bax
The SmartFoxServer Team
sstark
Posts: 77
Joined: 21 Nov 2008, 16:06

Postby sstark » 28 Jul 2009, 15:57

Bax, I think that may solve the issue, yes, IF:

those methods do not add additional server send / receive calls. If it is asking the server for the information, it defeats the purpose.
User avatar
Bax
Site Admin
Posts: 4517
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 29 Jul 2009, 08:01

Those informations are available on the client. No requests to the server are sent (in fact the mentioned methods return a value immediately, you don't have to wait for an asynchronous event).
Paolo Bax
The SmartFoxServer Team
sstark
Posts: 77
Joined: 21 Nov 2008, 16:06

Postby sstark » 29 Jul 2009, 18:42

perfect, thank you very much.

I would still suggest the change to user name just for unification's sake. Keeping the libraries as similar as possible, to me, seems important... though not as important as efficiency. Is there a reason behind this? I am just curious. (I like taking things apart and putting them back together ;))
User avatar
Bax
Site Admin
Posts: 4517
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 30 Jul 2009, 07:15

The reason is that internally OpenSpace doesn't keep track of the user data. It simply creates the avatar assigning it the same id of the user, while a different name could be assigned when creating the avatar.
Paolo Bax
The SmartFoxServer Team
sstark
Posts: 77
Joined: 21 Nov 2008, 16:06

Postby sstark » 30 Jul 2009, 15:41

thank you for taking the time to explain your process.

Return to “OpenSpace v1 discussions and help”

Who is online

Users browsing this forum: No registered users and 3 guests