Class SFS2X.Requests.System.FindUsersRequest

Retrieves a list of users from the server which match the specified criteria.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new FindUsersRequest instance.

Class Detail

SFS2X.Requests.System.FindUsersRequest(expr, target, limit)
Creates a new FindUsersRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

By providing a matching expression and a search scope (a Room, a Group or the entire Zone), with this request it is possible to find those users matching the passed criteria on the server side and retrieve them by means of the userFindResult event.

The following example looks for all the users whose "age" User Variable is greater than 29:

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.USER_FIND_RESULT, onUserFindResult, this);
	
	// Create a matching expression to find users with an "age" variable greater than 29:
	var exp = new SFS2X.Entities.Match.MatchExpression("age", SFS2X.Entities.Match.NumberMatch.GREATER_THAN, 29);
	
	// Find the users
	sfs.send(new SFS2X.Requests.System.FindUserRequest(exp));
}

function onUserFindResult(evtParams)
{
	console.log("Users found: " + evtParams.users);
}
Parameters:
{MatchExpression} expr
A matching expression that the system will use to retrieve the users.
{*} target Optional, Default: null
The name of a Group or a single SFSRoom object where to search for matching users; if null, the search is performed in the whole Zone.
{Number} limit Optional, Default: 0
The maximum size of the list of users that will be returned by the userFindResult event. If 0, all the found users are returned.
See also:
SFS2X.SmartFox#send
SFS2X.SFSEvent.USER_FIND_RESULT
SFS2X.Entities.Match.MatchExpression
SFS2X.Entities.SFSRoom