Page 1 of 1

Missing userlist update when joining a room - AS3 API

Posted: 07 Feb 2007, 20:03
by boegh
I think I have uncovered a bug in AS3 client-side API.

Two users 1 and 2, three rooms A, B and C.

Both users enters room A
User 1 go to room B
User 2 go to Room C
Now Room A is empty
User 1 go to room A

The client receives the message from the server and it contains one user as expected:

[trace] [ RECEIVED ]: <msg t='sys'><body action='joinOK' r='1'><pid id='1'/><var
s /><uLs r='1'><u i='15' m='0' s='0' p='1'><n><![CDATA[guest_2968]]></n><vars><v
ar n='color' t='n'><![CDATA[16777008]]></var><var n='y' t='n'><![CDATA[-224]]></
var><var n='x' t='n'><![CDATA[66]]></var></vars></u></uLs></body></msg>, (len: 289)

The onJoinRoom event is received also as expected and I do the following:

users = evt.params.room.getUserList();
trace("Users in room " + room.getId());
for each (user in users) {
trace("user: " + user.getId());
}

Which gives me this output:

[trace] Users in room 1
[trace] user: 14
[trace] user: 15

Which is NOT at all what I expected - there should only be one user in the room. To me it looks like the client code forgets to update some internal state.

Regards
Kaare

Posted: 07 Feb 2007, 21:23
by Lapo
Thanks for the submission. We'll do a test on our side and we'll let you know.
Stay tuned.

Posted: 08 Feb 2007, 16:10
by Lapo
this sounds really odd. If what you say is correct then the Flex example chat wouldn't work. If you check it with 2 clients you will see that the user list behaves correctly.

Also the code we use in the example is really similar:

Code: Select all

public function onJoinRoom(evt:SFSEvent):void
{
	var room:Room = evt.params.room as Room						
	var provider:ArrayCollection = new ArrayCollection()
	
	// Set the selection in the room list component
	setRoomListSelection(room)
	
	// Cycle through all users in the list and add them to the provider
	for each(var u:User in room.getUserList())
	{
		provider.addItem( {label:u.getName(), data:u.getId()} )
	}
	
	// Add a sort field to the room list component. Names will be sorted alphabetically
	if (provider.sort == null)
	{
		var sort:Sort = new Sort()
		sort.fields = [new SortField("label")]
		
		provider.sort = sort
	}
	
	provider.refresh()
	userList.dataProvider = provider
	
	ta_chat.htmlText = "<font color='#cc0000'>{ Room <b>" + room.getName() + "</b> joined }</font><br>"
}
as you can see we essentially use the same for ... each iteration.

Can you provide the code that creates the bug?

Posted: 08 Feb 2007, 16:59
by boegh
Your example has the exact same bug ;)

Do like I described and watch the user list - it shows the same unexpected behavior. Users are not correctly removed when you rejoin a room.

Regards
Kaare

Posted: 09 Feb 2007, 18:05
by Lapo
You are right. I missed one of the steps you mentioned.
Fixing this issue shouldn't take much, but we want to run a few extra tests.
We'll release an update in a few days.

If you need the fix before, just drop us an email: we'll be able to provide a quick patch before the official update.

cheers

Posted: 09 Feb 2007, 20:16
by boegh
Sounds good - thanks.

/k

Posted: 12 Feb 2007, 11:31
by Lapo
The patch is ready ( it also contains the 1.5.1 server side patch which is not needed in order to fix the reported issue )
All you have to do is unzip the archive and copy the new swc library file to a folder of your choice.

You can download the patch from here