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.
Updating userList, playerList client side with AS3
-
protodaniel
- Posts: 1
- Joined: 17 Jan 2011, 21:53
- Contact:
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
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
love