Expand my Community achievements bar.

UserManager > UserCollection > Loop of Remove and Add user

Avatar

Level 1

I have no idea why the Adobe team has written the following:

removeUserFromCollection(userD);

var newD:UserDescriptor = userD.clone();

newD.voiceStatus = p_evt.item.body.voiceStatus;

addUserToCollection(newD);

Which means, as any time a custom field or a voice status is refreshed, the user is removed then added again! So the memory taken is terrible and that is very very stupid, why they didnt update the item instead of removing/adding it? Any idea to get the real online users?

5 Replies

Avatar

Former Community Member

Gosh, you're a bit of an ass. No offense, of course.

Where are you seeing this code? It looks as though you're using an old version of the SDK, as this was an issue that was fixed months ago - the descriptor is pulled out of the collection, modified, and re-inserted. The latest code doesn't create a new descriptor. This is done because users who are currently speaking are sorted to the top of the userCollection. It takes O(2lgN) to perform the operation, which is fairly reasonable.

I don't understand the last part of your question. "Where to get the real online users" isn't really a phrase I can parse.

nigel

Avatar

Level 1

My problem is if I add a CollectionChange event listener to the UserManager.UserCollection in order to display properly the list of online users, my event listener is called with Remove/Add/Remove/Add .... always!

And as a result, all my components using this ArrayCollection are blinding ;-( Also my beautiful MSN like popup ;-) notification is driving crazzyyyyyyyyy

What I am doing now, is I created a new SharedCollection (UserDependent) where I add manually the current User and I have created a Timer of 500ms to check if the user is speaking etc ... (like Adobe did for the VideoDisplay component).... It's working fine now, but still, I don't understand a such code!

Avatar

Former Community Member

I don't think you're explaining what you're trying to accomplish very well. Is this using the Flex SDK or the plain Flash-only one? If you're just looking to notify as new users are coming or leaving, try using UserManager.userCreate and UserManager.userRemove. If you're using the Flex SDK, then just bind whatever List component you need to the UserManager.userCollection, and it will manage display updates for you.

Using a SharedCollection seems like a wasteful approach - if every client connected is running the same code when a user comes and goes (adding or removing them to/from a collection) then there's no need to make the collection shared, since they should all already be synchronized. You're essentially doubling the amount of messages sent for no reason.

I'm feeling a little less worried that you've found performance improvements that you aren't sharing, at least.

nigel

Avatar

Level 1

I am coding in Flex, I have only 1 Roster UI component.

I enable Audio.

2 users are in the application, and the roster's items are flashing all the time, bcoz I am using URL as icon and bcoz the items are removed/added all the time ... I admit if you let the demo with the default user icons, no problem! But in a real application, its horrible!

But you are 100% right, the 2 events CREATE and REMOVE are working fine! And I don't need a such SharedCollection any more, thanks!

Avatar

Former Community Member

Well, you could also cache the icon images so that they don't reload/flash all the time... See Ely Greenfield's superimage component.

nigel