Buddylist Persister: loadList (String userName) parameter

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

fabianres@live.com.mx
Posts: 40
Joined: 14 Apr 2010, 17:40

Buddylist Persister: loadList (String userName) parameter

Postby fabianres@live.com.mx » 03 Aug 2011, 22:43

Here´s the situation:

I developed an application with a facebook login, which extracts your fb first and last name, then the app requests a username which will be your online alias. These are then stored in a db.

Each user has a buddylist, so I developed a custom buddylist persister class. The lists will also be stored in the db at savelist.

The buddylist class has a loadList (String userName) method, to load the user´s buddylist, yet it seems that I can only give it the current username parameter (String userName).

I need to pass the loadlist method more than just the username parameter, because the loadlist needs to query the specific user´s fb first and last name to extract the appropiate buddylist.

Is there a way to pass other string parameters from the client?

Even if the userName parameter was the only parameter to be passed, ex. "John", how could I filter if there where 10 other users with username "John" in my db?

Did anyone think about this before?

Is there a way to pass the loadlist method other string parameters other than the userName?

I need these strings so I can make a db query so I can get the appropriate buddylist.
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 04 Aug 2011, 05:22

Are you using a entirely custom buddy list database? That is, you're not using the __sfscore__ h2 database?

On a side note, have you thought about facebook users with same firstname and surname? Have you considered using an auto-generated unique sfs username (i.e. user_003321), and store the firstname as a user variable which will be used for display purposes? That way, there won't be any conflict of names.

I have not played with the facebook API yet, but maybe there is another identification to uniquely identify a user (such as email address or facebook id) which you can use instead of firstname + surname combination. The reason for this, is that facebook users can change their firstname or surname which may cause problems with you app.
Smartfox's forum is my daily newspaper.
fabianres@live.com.mx
Posts: 40
Joined: 14 Apr 2010, 17:40

Postby fabianres@live.com.mx » 04 Aug 2011, 19:12

That is correct. I am using a custom buddylist mysql database.

You are also correct in using the fb id to uniquely identify a user instead of the firstname + surname. Much better indeed.

The problem here is that the buddylist persister class, loadlist method can apparently only pass a single username string parameter so I could further query into the database to identify the current user.

On the client side, I would replace the myUsername variable for the fb id, so I could pass this to loadlist as a parameter and make the query within the method.

smartFox.login(smartFox.defaultZone, myUsername, "")

That would solve the user identification within the buddy persister class problem.

Unfortunately this gives way to another problem, which is that now the user´s myUsername and display name is now the fb id number too.

Is there a way to have another string variable be the user´s username?
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 05 Aug 2011, 06:02

Is there a way to have another string variable be the user´s username?


Of course. Like I said before, use the user's variable to store additional information about that user such as firstname. That is, I'm referring to the setUserVariables() method (see docs for more info and examples). So, the SFS username would be the facebook id, and the first name will be stored as a user variable which can be received anytime in any room except a limbo room, and can be accessible from other clients anytime. Use this 'stored' variable for display name instead of the SFS username.
Smartfox's forum is my daily newspaper.
fabianres@live.com.mx
Posts: 40
Joined: 14 Apr 2010, 17:40

Postby fabianres@live.com.mx » 08 Aug 2011, 22:59

So I have continued with this and as we previously established, use the
user's variable to store additional information about that user such as
firstname, while we leave the username for the facebook id.

Everything works, but now a new problem arises thanks to this.

It has to do with how the buddylist will handle these last
modifications.

So the buddylist is used to handling other users´ sfx username as
its parameter to be able to add buddies etc, remove buddies, etc.

Of course now our username is a fb id, a number string.

When we proceed to select a user (an avatar), to add him to our list
as a buddy I can manage to retrieve his avatar id (which is the same as
the smartfox id), with which I can now retrieve his sfx username (his
fb number string) and consequently his avatar name, that is stored as a
variable. This is because I obviously can´t have have a list of fb id
numbers as my buddylist if I were using the sfx names. I have to get
each user´s name which is now stored as variables in each user object.

So this is the downside I guess, and it gets more challenging next.

So lets say I now have a list of readable names on my buddylist. Since
they are not the usernames themselves, smartfox won´t acknowledge
offline variables. In other words, I guess I won´t be able to tell if
they are currently online or not in some other room in the zone.

Secondly, lets say I wanted to join these buddies ( a neat function I
had already ) elsewhere, again since they are just variable names, no
way to know with these names if they are around.

Of course there could be a hard way to solve this, I would have to make
a function that speaks to a special server-side extension that checks
my current buddylist names (the variable) against online sfx usernames
on the current zone, pair the variable names to their corresponding sfx
usernames ( search every user object names´ variables ), and if they
are online be able to join them.

This is the only way I can envision making this happen and solving
this, on the server side.

This originally is done on the client side without much hassle, but by
making the username the fb id, this seems inevitable.

So my questions are:

Is there a way to avoid this hassle?

Is there a way to still accomplish this on the client side alone?

I need a hint here, somebody throw me a bone please.
fabianres@live.com.mx
Posts: 40
Joined: 14 Apr 2010, 17:40

Postby fabianres@live.com.mx » 09 Aug 2011, 19:23

Ok I should have read the documentation throughly first, my bad.

I am going to try solving this with the setBuddyVariables().

I will let you all know how it turns out.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 55 guests