Sending user list back to flash

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
eventdave
Posts: 18
Joined: 02 Jul 2010, 14:12

Sending user list back to flash

Post by eventdave »

I am trying to get a list of all users in a zone back into my flash client.

I am using a server side extension to get a list of all users in a zone.

var response = {};
response._cmd = "getAllUsersResponse";
//send a response to all clients in the zone
var zone = _server.getCurrentZone();

var userList = zone.getUserList();
trace("total users=" + zone.getUserCount()); //this bit works

//send response to submitting user
_server.sendResponse(response, -1, null, [user]);

I get a reply back in my flash client but nothing in the response containing a userlist.

I really need an urgent answer on this one, so grateful for any help.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

Hi. If the code you posted is the full code, then you're forgetting adding the userList to the response Object.

try something like:

response.userList = zone.getUserList();

then in the client you get the user list by:

smartfox.onExtensionResponse(o:Object){
if(o._cmd == "getAllUsersResponse"){
var receivedUserList = o.userList;
}
}
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

You would also have to iterate over the userList and then populate an array of objects with the data you want, otherwise you would be sending a lot of data you don't need.
Smartfox's forum is my daily newspaper.
Post Reply