| Package | com.smartfoxserver.v2.requests.game |
| Class | public class QuickJoinGameRequest |
| Inheritance | QuickJoinGameRequest com.smartfoxserver.v2.requests.BaseRequest |
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 could be found and joined, the roomJoin event is dispatched to the requester's client.
See also
| Method | Defined By | ||
|---|---|---|---|
Creates a new QuickJoinGameRequest instance. | QuickJoinGameRequest | ||
| QuickJoinGameRequest | () | Constructor |
public function QuickJoinGameRequest(matchExpression:MatchExpression, whereToSearch:Array, roomToLeave:Room = null)Creates a new QuickJoinGameRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
ParametersmatchExpression:MatchExpression — A matching expression that the system will use to search a Game Room where to join the current user.
| |
whereToSearch:Array — An array of Room 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:Room (default = null) — A Room object representing the Room that the user should leave when joining the game.
|
See also
private function someMethod():void
{
sfs.addEventListener(SFSEvent.ROOM_JOIN, onRoomJoin);
// Create a matching expression to find a Darts game with a "maxBet" variable less than 100
var exp:MatchExpression = new MatchExpression("type", StringMatch.EQUALS, "darts").and("maxBet", NumberMatch.LESS_THAN, 100);
// Search and join a public game within the "games" Group, leaving the last joined Room
sfs.send(new QuickJoinGameRequest(exp, ["games"], sfs.lastJoinedRoom));
}
private function onRoomJoin(evt:SFSEvent):void
{
trace("Successfully joined Room: " + evt.params.room);
}