Quickly joins the current user in a public game.

Namespace: Sfs2X.Requests.Game
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.0.0 (1.7.0)

Syntax

C#
public class QuickJoinGameRequest : BaseRequest

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:
 Copy imageCopy
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"]);        // Windows Universal
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    Sfs2X.Requests.Game..::..QuickJoinGameRequest

See Also