how to get the buddylist length from the serverside?

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

Moderators: Lapo, Bax

Post Reply
mhdside
Posts: 236
Joined: 04 May 2008, 07:57
Location: Egypt

how to get the buddylist length from the serverside?

Post by mhdside »

It might be a noob question, How to get a user's buddylist details like the buddies themselves, and the list length from the server side?
Mahmoud Badri
Senior actionscript developer
http://www.el3ab.com
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

You could use BuddyListManager to do this.

Firstly, get the zone's buddy list manager --> zone.getBuddyManager();

And, secondary use the loadBuddyList method to fetch the buddy list of a user. Then get its length.

I haven't tried this - let me know if it doesn't work.
Smartfox's forum is my daily newspaper.
mhdside
Posts: 236
Joined: 04 May 2008, 07:57
Location: Egypt

Post by mhdside »

Yeah, it works buddy! thanks for your help.

now I wonder whats the difference between loadBuddyList() and getBuddyList() :?
Mahmoud Badri
Senior actionscript developer
http://www.el3ab.com
mhdside
Posts: 236
Joined: 04 May 2008, 07:57
Location: Egypt

Post by mhdside »

Also the following function in the java serverside doesnt work:

Code: Select all

removeBuddy(java.lang.String owner, java.lang.String buddyName)
any info why?
Mahmoud Badri
Senior actionscript developer
http://www.el3ab.com
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

now I wonder whats the difference between loadBuddyList() and getBuddyList()

I'm not sure actually. What do you get from getBuddyList() ?

As for your second question, here's a snippet from the documentation:
Methods such as addBuddy, removeBuddy etc... will perform the change on the server side but won't dispatch any event back to the clients. When you have done all the changes to one or more buddy lists you can broadcast the changes by calling the sendBuddyListUpdate() method.
Smartfox's forum is my daily newspaper.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

I think I can help here :-P

The buddylists are saved in a database (i think in a h2database in sfs1.x), so sfs needs to load a buddylist from the database before editing it. For better performance, sfs only loads the necessary buddyLists, i mean, it only loads the buddylists of the users that are online.

So:

- loadBuddyList() - loads the buddyList from the database (idk if it returns it or not, as i haven't tried it in sfs1.x)
- getBuddyList() - returns an already loaded buddyList.

Sorry, but idk when to use each one in sfs1.x, as i only tried it in sfs2.x.
Hope this was helpful ;-)

*EDIT*

Just remembered one thing. You usually use loadBuddyList to access a buddyList from an user that is offline (so his buddyList isnt loaded) and then perform changes such as removeBuddy, addBuddy, etc. Then you need to save it (at least in sfs2.x you need).
Normally you use the getBuddyList to perform changes in buddyLists that are already loaded.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Post Reply