Class 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 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
    • 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 *