Packagecom.smartfoxserver.v2.requests.game
Classpublic class QuickJoinGameRequest
InheritanceQuickJoinGameRequest Inheritance com.smartfoxserver.v2.requests.BaseRequest

Quickly joins the current user in a public game.

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.

View the examples

See also

MatchExpression
JoinRoomRequest
roomJoin event


Public Methods
 MethodDefined By
  
QuickJoinGameRequest(matchExpression:MatchExpression, whereToSearch:Array, roomToLeave:Room = null)
Creates a new QuickJoinGameRequest instance.
QuickJoinGameRequest
Constructor Detail
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.

Parameters
matchExpression: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

Examples
The following example makes the user quickly join a public game:
     
     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);
     }