Getting the room a buddy is in (and NOT joining)

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

User avatar
death_au
Posts: 8
Joined: 23 Mar 2010, 03:17

Getting the room a buddy is in (and NOT joining)

Postby death_au » 23 Jul 2010, 04:56

I'm using a buddy list for the first time, and I'm wondering if what I'm trying to do is possible.
I want to have a room list, as well as a list of rooms that your buddies are in. So I'll end up with two lists, one listing all the rooms (room name and the current/max users), and another that lists only the rooms buddies are in (room name, which buddy, and current/max users).
Is this possible?

What I have so far is this:

Code: Select all

smartfox.onBuddyList = function(bList:Array)
{
   trace("loaded buddy list from server");
   for (var i in bList)
   {
         trace(bList[i].name + (bList[i].isOnline ? "Online" : "Offline"));
         trace("in room:");
         smartfox.getBuddyRoom(bList[i]);
   }
}

smartfox.onBuddyListError = function(errorMsg:String)
{
   trace("Buddy list error: " + errorMsg);
}

smartfox.onBuddyListUpdate = function(buddy:Object)
{
   trace("Buddy List update for: " + buddy.name);
   trace("in room:");
   smartfox.getBuddyRoom(buddy);
}

smarfox.onBuddyRoom = function(idList:Array)
{
   var roomObj:Room = smartfox.getRoom(idList[0]);
   trace("Room name: " + roomObj.getName());
}

The buddy list appears to load correctly, and correctly reports online/offline, but the onBuddyRoom handler never seems to get called, and I'm not sure why.
Also, I'm aware of a potential problem with this approach: onBuddyRoom doesn't seem to know which buddy the room is for. I can probably find a way to work around this, but I need to actually get the room my buddy is in first...
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Jul 2010, 15:39

Probably setting the Room names inside a Buddy Variable is the easiest way.
Each Buddy will just need to update that variable every time they join a Room
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
death_au
Posts: 8
Joined: 23 Mar 2010, 03:17

Postby death_au » 24 Jul 2010, 01:02

Lapo wrote:Probably setting the Room names inside a Buddy Variable is the easiest way.
Each Buddy will just need to update that variable every time they join a Room

I'd thought of that after I posted but haven't had a chance to try it yet.
I'll give it a go, thanks Lapo. :D

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 28 guests