sfs2x.client.requests.game
Class QuickGameJoinRequest

java.lang.Object
  extended by sfs2x.client.requests.BaseRequest
      extended by sfs2x.client.requests.game.QuickGameJoinRequest
All Implemented Interfaces:
sfs2x.client.requests.IRequest

public class QuickGameJoinRequest
extends 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.

Example
The following example makes the user quickly join a public game:

 private void someMethod() {
     sfs.addEventListener(SFSEvent.ROOM_JOIN, new IEventListener() {
         public void dispatch(BaseEvent evt) throws SFSException {
             System.out.println("Successfully joined Room: " + evt.getArguments().get("room"));
         }
     });
     
     // Create a matching expression to find a Darts game with a "maxBet" variable less than 100
     MatchExpression exp = 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
     List roomNames = new ArrayList();
     roomNames.add("games");
     sfs.send(new QuickGameJoinRequest(exp, roomNames, sfs.getLastJoinedRoom()));
 }
 

See Also:
SFSEvent.ROOM_JOIN, MatchExpression, JoinRoomRequest

Field Summary
static java.lang.String KEY_GROUP_LIST
          * API internal usage only *
static java.lang.String KEY_MATCH_EXPRESSION
          * API internal usage only *
static java.lang.String KEY_ROOM_LIST
          * API internal usage only *
static java.lang.String KEY_ROOM_TO_LEAVE
          * API internal usage only *
 
Fields inherited from class sfs2x.client.requests.BaseRequest
AddBuddy, AdminMessage, AutoJoin, BanUser, BlockBuddy, CallExtension, ChangeRoomCapacity, ChangeRoomName, ChangeRoomPassword, CreateRoom, CreateSFSGame, FindRooms, FindUsers, GenericMessage, GetRoomList, GoOnline, Handshake, InitBuddyList, InvitationReply, InviteUser, JoinRoom, JoinRoomInvite, KEY_ERROR_CODE, KEY_ERROR_PARAMS, KickUser, LeaveRoom, Login, Logout, ManualDisconnection, ModeratorMessage, ObjectMessage, PingPong, PlayerToSpectator, PrivateMessage, PublicMessage, QuickJoinGame, RemoveBuddy, SetBuddyVariables, SetRoomVariables, SetUserPosition, SetUserVariables, SpectatorToPlayer, SubscribeRoomGroup, UnsubscribeRoomGroup
 
Constructor Summary
QuickGameJoinRequest(MatchExpression matchExpression, java.util.List<?> whereToSearch)
           
QuickGameJoinRequest(MatchExpression matchExpression, java.util.List<?> whereToSearch, Room roomToLeave)
          Creates a new QuickJoinGameRequest instance.
 
Method Summary
 void execute(ISmartFox sfs)
          * API internal usage only *
 void validate(ISmartFox sfs)
          * API internal usage only *
 
Methods inherited from class sfs2x.client.requests.BaseRequest
getId, getMessage, getTargetController, isEncrypted, setEncrypted, setId, setTargetController
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_ROOM_LIST

public static final java.lang.String KEY_ROOM_LIST
* API internal usage only *

See Also:
Constant Field Values

KEY_GROUP_LIST

public static final java.lang.String KEY_GROUP_LIST
* API internal usage only *

See Also:
Constant Field Values

KEY_ROOM_TO_LEAVE

public static final java.lang.String KEY_ROOM_TO_LEAVE
* API internal usage only *

See Also:
Constant Field Values

KEY_MATCH_EXPRESSION

public static final java.lang.String KEY_MATCH_EXPRESSION
* API internal usage only *

See Also:
Constant Field Values
Constructor Detail

QuickGameJoinRequest

public QuickGameJoinRequest(MatchExpression matchExpression,
                            java.util.List<?> whereToSearch,
                            Room roomToLeave)
Creates a new QuickJoinGameRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters:
matchExpression - A matching expression that the system will use to search a Game Room where to join the current user.
whereToSearch - 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 - A Room object representing the Room that the user should leave when joining the game.
See Also:
SmartFox.send(sfs2x.client.requests.IRequest), Room

QuickGameJoinRequest

public QuickGameJoinRequest(MatchExpression matchExpression,
                            java.util.List<?> whereToSearch)
See Also:
QuickGameJoinRequest(MatchExpression, List, Room)
Method Detail

validate

public void validate(ISmartFox sfs)
              throws sfs2x.client.exceptions.SFSValidationException
* API internal usage only *

Throws:
sfs2x.client.exceptions.SFSValidationException

execute

public void execute(ISmartFox sfs)
* API internal usage only *