Buddy List Framework

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

Moderators: Lapo, Bax

Post Reply
ramindeja
Posts: 74
Joined: 31 Mar 2008, 17:54

Buddy List Framework

Post by ramindeja »

Hi,

In our application, there are two ways two persons can be buddies:

1- send an email to invite a friend to join the world
2- ask the person in the same room

At first I had implemented my own APIs to add buddies and they were saved in my own SB table. However, after reading about the default SFS Buddy List framework, I decided to keep a buddy's personal information in my own DB but use the SFS framework for adding, removing, inviting etc.

My main utility of the SFS Buddy List framework was the fact that you can find out when a buddy is online or not. I assumed that my own implementation for the same functionality could be less efficient.

Now, in scenario 1 above, upon an invitation to signup, that person becomes the buddy of the inviter and vice versa. How do I disable the permission request if this is enabled in the config.xml? In this scenario no permission is required, this is only useful when a user explicitly invites another person in a room.

In resume, is it possible to change the Buddy List settings saved in the config.xml at runtime to make certain exceptions.


I also appreciate any suggestions or critiques regarding mixing my DB buddy information with the SFS framework :)

Cheers
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

In resume, is it possible to change the Buddy List settings saved in the config.xml at runtime to make certain exceptions.
You could configure the buddy list with the addBudddyRequest turned off. Then you could disable the client side AddBuddy action for security and wrap the addBuddy call into your own custom call to the extension.

Finally from your extension you decide if you can add the buddy directly (as in case n.2) or perform request a permission (as in case n.1?)

Hope I was clear enough

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
ramindeja
Posts: 74
Joined: 31 Mar 2008, 17:54

Post by ramindeja »

Thanks Lapo,

Just to make sure I understood you well

I can have something like this in my config.xml:

Code: Select all

<DisabledSysActions>
   <action>addBuddy</action>
</DisabledSysActions>
And under my zone:

Code: Select all

<BuddyList active="true">
   <size>200</size>
   <maxBuddyVariables>5</maxBuddyVariables>
   <mode>advanced</mode>

   <!-- Apply only for advanced mode -->
   <addBuddyPermission>false</addBuddyPermission>
   <offLineBuddyVariables>true</offLineBuddyVariables>
   <permissionTimeOut>10</permissionTimeOut>
   <mutualAddBuddy>true</mutualAddBuddy>
   <mutualRemoveBuddy>true</mutualRemoveBuddy>
</BuddyList>
I guess by disabling addBudddyRequest you meant addBuddyPermission.

I am going to do a test but, I assume that once the client uses the custom addBuddy, the extension can still dispatch the permission event (for case 2) by using the API requestAddBuddyPermission().

Thanks again.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

yes, looks good :)
Lapo
--
gotoAndPlay()
...addicted to flash games
ramindeja
Posts: 74
Joined: 31 Mar 2008, 17:54

Post by ramindeja »

I found an issue with the buddy list. I am not sure if I am doing something wrong or if the client API has a tiny bug.

If you look at the AS3 API in SysHandler.handleBuddyList(), it seems that the SmartFoxClient.buddyList keeps concatenating the buddies to an existing list:

Code: Select all

private function handleBuddyList(o:Object):void
{
   // ...
      
   if (bList != null && bList.b.length != null)
   {
      // ...
      
      if (bList.toString().length > 0)
      {              
         for each (var b:XML in bList.b)
         {
            // ...
            
            // HERE IS ADDING TO AN EXISTING LIST
            sfs.buddyList.push(buddy)
         }
      }
      
      // Fire event!
      params.list = sfs.buddyList
      evt = new SFSEvent(SFSEvent.onBuddyList, params)
      sfs.dispatchEvent(evt)
   }
   
   // Buddy List load error!
   else
   {
      // ...
   }
}
The problem is that, based on the Advance BuddyList sample, if you load the buddy list upon joining a room, each time you change a room, the buddies get duplicated since the buddyList is just adding the items received from the server.

Is there a call that I have to do before loadBuddyList() (clearBuddyList is deprecated)

One more question in this area, do mutualAddBuddy and mutualRemoveBuddy depend on the value of addBuddyPermission? In my test, the mutualAddBuddy kicks in only when addBuddyPermission is set to TRUE.

Thanks.
eggs
Posts: 46
Joined: 28 Apr 2008, 13:37
Contact:

Has this question been answered?

Post by eggs »

I discovered the same problem a few days ago and posted a question about it here in the forums:
The problem is that, based on the Advance BuddyList sample, if you load the buddy list upon joining a room, each time you change a room, the buddies get duplicated since the buddyList is just adding the items received from the server.

Is there a call that I have to do before loadBuddyList() (clearBuddyList is deprecated)


This post is almost 2 years old, has anyone found a solution in the meantime?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

The Buddy List must be loaded once, usually right after the login.
From that moment on you will only receive updates and you don't need to worry about anything else, just handle the events as explained in the documentation.

If this is still not clear to you take a look at the documentation and the provided examples, especially the AdvancedBuddyList example.
( Tutorial at chapter 8.16 of the docs )
Lapo
--
gotoAndPlay()
...addicted to flash games
eggs
Posts: 46
Joined: 28 Apr 2008, 13:37
Contact:

Post by eggs »

Thanks Lapo,

I actually did look at the documentation and the examples, and didn't find help there, which is why I came here :-)

I think the confusion (as the original poster pointed out), is in the source code for the tutorial itself.

Code: Select all

/**
		 * Handle successfull join
		 */
		function onJoinRoom(evt:SFSEvent):void
		{
			debugTrace("Successfully joined room: " + evt.params.room.getName())
			sfs.loadBuddyList()
		}
This application is designed for only one chat room. If I understand you correctly, people using this tutorial for applications with multiple chat rooms need to modify the code in onJoinRoom function.

Thanks for your response.

K
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

You definitely have point here. We'll make sure to add more details in the docs for that example
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply