new QuickJoinGameRequest(matchExpression, whereToSearch[, roomToLeave])

Creates a new QuickJoinGameRequest instance. The instance must be passed to the SmartFox.send() method for the request to be executed.

Using this request, by providing a matching expression and a list of Rooms or Groups, SmartFoxServer can search for a matching public Game Room and immediately join the user into that Room as a player.

If a game is found and can be joined, the roomJoin event is dispatched to the requester's client.

Example

This example makes the current user join a Darts game with a "maximum bet" condition.

function someMethod()
{
	sfs.addEventListener(SFS2X.SFSEvent.ROOM_JOIN, onRoomJoin, this);

	// Create a matching expression to find a Darts game with a "maxBet" variable less than 100
	var exp = new SFS2X.MatchExpression("type", SFS2X.StringMatch.EQUALS, "darts").and("maxBet", SFS2X.NumberMatch.LESS_THAN, 100);

	// Search and join a public game within the "games" Group, leaving the last joined Room
	sfs.send(new SFS2X.QuickJoinGameRequest(exp, ["games"], sfs.lastJoinedRoom));
}

function onRoomJoin(evtParams)
{
	console.log("Successfully joined Room: " + evtParams.room);
}

Parameters

Name Type Optional Description

matchExpression

 

 

A matching expression that the system will use to search a Game Room where to join the current user. If null is passed, the first available game Room is joined.

whereToSearch

 

 

An array of SFSRoom objects or an array of Group names to which the matching expression should be applied. The maximum number of elements that this array can contain is 32.

roomToLeave

 

Yes

A SFSRoom object representing the Room that the user should leave when joining the game.

Defaults to null.

See also
SmartFox#send
SFSEvent.ROOM_JOIN