Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Combining CustomRoster and KnockingQueue Examples

Avatar

Former Community Member

Hello all (I think Arun is the one to ask on this topic),

I have implemented the knocking queue in my app. and it works great!  What I want to do now is add the ability to remove a user from the room.  I am just adding a "Remove" button that will allow the host to remove a user which is selected in the "Accepted" list.  Essentially I want to combine the KnockingQueue and the CustomRoster examples.  I tried this, but quickly realized that they are populating the list components they are using in different ways.  For example, the KnockingQueue example is using {label:item.descriptor.displayName,descriptor:item.descriptor} to populate the acceptedArray (and hence, the "accepted" list), whereas the CustomRoster example is using {cSession.userManager.userCollection} to populate the roster list.  When I add a handler to kick someone out it throws an error.  Here is the CustomRoster remove handler:

private function onRemoveClick(p_evt:MouseEvent):void

{

     var userID:String=UserDescriptor(acceptedList.selectedItem).userID;

     cSession.userManager.removeUser(userID);

}

I understand why the error is being thrown (the KnockinQueue example is using the user descriptor as the data source for the "accepted" list and the CustomRoster is using the userID as the data source to remove the user), however I'm not sure how I should go about changing the code.  I'm just afraid of breaking everything.  Is there a way I can populate the "accepted" list with the userCollection that has been allowed into the room, so that I can then click on an item in the list and get a userID with which to remove them?  Also, what happens when I remove a user?  Do they go back to the "lobby" or do they dissapear into the ether somewhere?

Thanks for any help or advice you can give,

Matt

7 Replies

Avatar

Employee

Hi Matt,

Can you post your error.

Technically, you are removing the user the right way. You shouldnt worry about updating knocking Queue as user list keeps changing, as LCCS should be doing it for you.

As to removing the user, they disappear into Ether. If you want them in lobby, you can change their userRole UserRoles.LOBBY (or set it to 5)

Thanks

Arun

Avatar

Former Community Member

Arun,

Here is the error:

TypeError: Error #1034: Type Coercion failed: cannot convert Object@c22aac1 to com.adobe.rtc.sharedManagers.descriptors.UserDescriptor.

    at StaffApp/onRemoveClick()[C:\Documents and Settings\Matt\Adobe Flash Builder 4\StaffApp\src\StaffApp.mxml:240]

    at StaffApp/___StaffApp_Button4_click()[C:\Documents and Settings\Matt\Adobe Flash Builder 4\StaffApp\src\StaffApp.mxml:450]

Here is the code which updates the array for the acceptedList:

if ( item.status == UserQueueItem.STATUS_ACCEPTED )

{

     acceptedArray.addItem({label:item.descriptor.displayName,descriptor:item.descriptor});

}

And here is the event handler for the "Remove" button:

private function onRemoveClick(p_evt:MouseEvent):void
{
     var userID:String=UserDescriptor(acceptedList.selectedItem).userID;
     cSession.userManager.removeUser(userID);
}

The error only occurs at runtime when I click on the "Remove" button.  I think the problem is that the items in the acceptedList don't contain the userID in them, so when I click to remove a user the onRemoveClick() handler throws an error.  The only option seems to be to change the data which is stored in the acceptedList so that it contains the userID for each user.  I'm just not sure how to do that without damaging the knocking queue.

Thanks,

Matt

Avatar

Employee

Hi Matt,

The error is definitely Type Coercion error. If you can mail your entire app, I could debug it for you.

If I make a wild guess,

private function onRemoveClick(p_evt:MouseEvent):void

{

var userID:String=UserDescriptor(acceptedList.selectedItem).userID;

cSession.userManager.removeUser(userID);

}

It must be this line var userID:String=UserDescriptor(acceptedList.selectedItem).userID;

And it should be changed to acceptedList.selectedItem.userID … Using a debugger would help you narrow down the issue for you.

Thanks

Arun

From: Adobe Forums <forums@adobe.com<mailto:forums@adobe.com>>

Reply-To: "jive-61736184-2s3s-2-2cbou@mail.forums.adobe.com<mailto:jive-61736184-2s3s-2-2cbou@mail.forums.adobe.com>" <jive-61736184-2s3s-2-2cbou@mail.forums.adobe.com<mailto:jive-61736184-2s3s-2-2cbou@mail.forums.adobe.com>>

Date: Fri, 23 Sep 2011 07:22:09 -0700

To: Arun <aponnusa@adobe.com<mailto:aponnusa@adobe.com>>

Subject: Combining CustomRoster and KnockingQueue Examples

Re: Combining CustomRoster and KnockingQueue Examples

created by phaseblue<http://forums.adobe.com/people/phaseblue> in Adobe LiveCycle Collaboration Service - View the full discussion<http://forums.adobe.com/message/3934254#3934254

Avatar

Former Community Member

Arun,

I sent the .fxp to your email.  Sorry I didn't reply to your post sooner, but it looked like the Adobe servers were having trouble a couple of days ago and I wasn't able to login.

Thanks again,

Matt

Avatar

Former Community Member

Arun,

I think I might have found a solution!  I was looking at older post in the forum and I found out that a guest who is sitting in the lobby apparently does not have a userDescriptor (does this mean that they also don't have a userID?).  Because of this, there might not be a way to extract a userID at that time and use it later on when I am populating the "accepted" list (thereby making it easier to kick that user out).  On the other hand, the customRoster example is using dataProvider="{cSession.userManager.userCollection}" to display the current users who are in the room, and this is actually better than using acceptedArray.addItem({label:item.descriptor.displayName,descriptor:item.descriptor}); to populate the "accepted" list because by using cSession.userManager.userCollection you are actually showing the "true" list of users who are absolutely in the room.  Also, it will not show users who are in the "lobby".  I did a test and got it to work!

In my StaffApp I changed the knocking queue section to use the user list from the customRoster examples instead of the "accepted" list from the knockingQueue example:

<s:Button label="Kick Out" enabled="{rosterList.selectedIndex!=-1}" click="kickOut()"/>

<mx:List id="rosterList" width="300" height="350" dataProvider="{cSession.userManager.userCollection}" labelFunction="userLabel"/>

I also added the code for kicking people out:

protected function kickOut():void

{

     var userID:String=UserDescriptor(rosterList.selectedItem).userID;

     cSession.userManager.removeUser(userID);

}

In the ClientApp I set up an event listener inside the onMyAccept() function (_userManager is defined at the top of the script block):

_userManager.addEventListener(UserEvent.USER_BOOTED,onCleared);

Here is the function in the ClientApp which handles the user_booted event:

private function onCleared(p_evt:UserEvent):void

{

     knockingUI.removeAllElements();

}

I suppose I could try to get the userID from the item.descriptor object for a user who is waiting in the "lobby", but I think that using the userManager to display users who are in the room does seem to be more efficient and accurate than using an array of users who have been accepted into the room, but (through some server error) might not actually have entered..

What do you think of this Arun?  I'm not sure if setting up the user_booted event listener on the userManager is the best way to do it, but it works.  Please tell me if I this is the best way to go about this.  I would love to get some feedback on this.

Thanks,

Matt

Avatar

Employee

Hi Matt,

Sincere apologies for not looking into your code. The task involved setting up your code, and our team was busy

But you figured out things on your own.

To answer your other question, When a user is removed forcefully as is the case in your app, you must listen to UserEvent.USER_BOOTED event. UserEvent.USER_REMOVE is an event that is dispatched when users leave the room on their own.

So what you are doing looks right to me.

Thanks

Arun

From: Adobe Forums <forums@adobe.com<mailto:forums@adobe.com>>

Reply-To: "jive-211244504-2s3s-2-2co4w@mail.forums.adobe.com<mailto:jive-211244504-2s3s-2-2co4w@mail.forums.adobe.com>" <jive-211244504-2s3s-2-2co4w@mail.forums.adobe.com<mailto:jive-211244504-2s3s-2-2co4w@mail.forums.adobe.com>>

Date: Mon, 3 Oct 2011 00:02:42 -0700

To: Arun <aponnusa@adobe.com<mailto:aponnusa@adobe.com>>

Subject: Combining CustomRoster and KnockingQueue Examples

Re: Combining CustomRoster and KnockingQueue Examples

created by phaseblue<http://forums.adobe.com/people/phaseblue> in Adobe LiveCycle Collaboration Service - View the full discussion<http://forums.adobe.com/message/3950384#3950384

Avatar

Former Community Member

No problem Arun!  I appreciate you taking the time that you have done already to help!

No, I just have to figure out how to remove the staff (i.e. OWNER) from the roster list so that he can't kick himself out

I might have to update the list in a function every time someone is accepted or removed from the room rather than binding to the userManager.userCollection.  When I get this sorted out I will post the solution here.

Thanks,

Matt