Page 1 of 1

Sending user list back to flash

Posted: 07 Jul 2011, 20:11
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.

Posted: 07 Jul 2011, 20:22
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;
}
}

Posted: 08 Jul 2011, 06:39
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.