Page 1 of 1

Updating userList, playerList client side with AS3

Posted: 17 Jan 2011, 22:16
by protodaniel
Hi guys,

I'm new to multiplayer game development and I'm trying to wrap my head around the optimization that needs to be in place.

I've noticed that the data for a room rarely gets updated client side beyond the User count change. So userList, and playerList will return empty after a JoinRoom event even if the userCount shows the right number of users on a Room.

I'm trying to create a game with 4 rooms, 2 players per room (for testing) and I would like to display the names of the players in each room so the user can choose to join a known friend (probably not good practice with potentially gazillion users and rooms) is there a way to do this on the client side or do I need to do a java extension?

Thank you!

- D.

Posted: 18 Jan 2011, 13:55
by wajdiazar
hi,

i had this problem before but i solve it this way:

you put eventlistener for User Count Change

sfs.addEventListener(SFSEvent.onUserCountChange, usersCountUpdated);


private function usersCountUpdated(e:SFSEvent)
{
//selectedRoom is a public variable that i create to save the name of the selected room
var users = sfs.getRoomByName(selectedRoom).getUserList();
//users now is object that holds all users in our room
updataUsersList(users);

}

private function updataUsersList(users)
{
var list:List = usersAv;// users list UIComponent
list.removeAll();

for (var i in users)
{
if (users.getName().indexOf(thisUser) < 0)
{
var obj:Object = new Object();
obj.name = users.getName();
obj.id = users.getId();
obj.label = users.getName();
list.addItem(obj);
}
}
}

i hope this help :)

Posted: 22 Mar 2011, 02:47
by nunobarao
Hi wajdiazar, iv tried your code but it trace an error .getName , it is necessary to create any extension for this? or the error is for somethingeles?

Thank you

Posted: 23 Mar 2011, 16:34
by Bax
The list of users inside a Room can be retrieved on the client only if it joined the same Room. Otherwise you have to go your own way using a server-side Extension.