Click or drag to resize

QuickJoinGameRequest Class

Quickly joins the current user in a public game.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.Requests.GameQuickJoinGameRequest

Namespace:  Sfs2X.Requests.Game
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class QuickJoinGameRequest : BaseRequest
Constructors
Remarks
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 ROOM_JOIN event is dispatched to the requester's client.

Examples
The following example makes the user quickly join a public game:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.ROOM_JOIN, onRoomJoin);

    // 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
    sfs.Send( new QuickJoinGameRequest(exp, new List<string>(){"games"}, sfs.LastJoinedRoom) );
}

void OnRoomJoin(BaseEvent evt) {    
    Console.WriteLine("Successfully joined Room: " + (Room)evt.Params["room"]);                         // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Successfully joined Room: " + (Room)evt.Params["room"]);        // UWP
}
See Also