Expand my Community achievements bar.

Custom Roster List

Avatar

Former Community Member

Hello all,

I'm trying to make a custom roster list that does not show the room owner

on the list.

I have a user queue with an "Accepted" list.  The room owner can select a

name from the list and click a "Remove" button to kick the user out.  If I

use the standard dataProvider="{cSession.userManager.userCollection}"

then the owner is able to kick himself out of the room.  Obviously, I don't

want to allow this as the owner might inadvertently kick himself out.

The only way I can think of how to resolve this is to bind the roster's

dataProvider to an "accepted" arrayCollection and update it every time

someone is allowed into the room or kicked out.  I would also need to

respond to sync events where a user closes his/her connection with the

room.  This seems like a bit of work just to keep track of users who are

actually in the room.  Does anyone know of an easier way to do this?

Thanks,

Matt

1 Reply

Avatar

Former Community Member

I might have found a solution to this!

I created 3 event listeners for users entering, leaving, and being kicked out of a room:

_userManager.addEventListener(UserEvent.USER_CREATE, onUserCreate);

_userManager.addEventListener(UserEvent.USER_REMOVE, onUserRemove);

_userManager.addEventListener(UserEvent.USER_BOOTED, onUserBooted);

I then added the 3 handlers for the events:

privatefunction onUserCreate(p_evt:UserEvent):void{
updateRosterList();
}

private function onUserRemove(p_evt:UserEvent):void

{

updateRosterList();

}

private function onUserBooted(p_evt:UserEvent):void

{

updateRosterList();
}

Then, I created the functio which updates the "acceptedList":

protected function updateRosterList():void

{

var rosterListArray:ArrayList = new ArrayList();
for(var i:int=0; i<cSession.userManager.userCollection.length; i++)
{
     
var
uDesc:UserDescriptor=_userManager.userCollection[i];
if (uDesc.userID != _userManager.myUserID)
{
rosterListArray.addItem({label:uDesc.displayName, descriptor:uDesc});
}

}
rosterList.dataProvider = rosterListArray;
}

I don't know if this is the most elegant solution, but it does work!

Any feedback would be greatly appreciated!

Matt