Page 1 of 1

os uses id when sfs uses name?

Posted: 21 Jul 2009, 16:27
by sstark
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?

Posted: 23 Jul 2009, 11:52
by Bax
Can you make an example where you need the username instead of the id in an OpenSpace event?

Posted: 23 Jul 2009, 15:39
by sstark
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.

Posted: 27 Jul 2009, 08:53
by Bax
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.

Posted: 28 Jul 2009, 15:57
by sstark
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.

Posted: 29 Jul 2009, 08:01
by Bax
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).

Posted: 29 Jul 2009, 18:42
by sstark
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 ;))

Posted: 30 Jul 2009, 07:15
by Bax
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.

Posted: 30 Jul 2009, 15:41
by sstark
thank you for taking the time to explain your process.