QuickJoinOrCreateRoomRequest Class |
Namespace: Sfs2X.Requests
public class QuickJoinOrCreateRoomRequest : BaseRequest
Name | Description | |
---|---|---|
QuickJoinOrCreateRoomRequest(MatchExpression, ListString, RoomSettings) |
See QuickJoinOrCreateRoomRequest(MatchExpression, List<string>, RoomSettings, Room) constructor.
| |
QuickJoinOrCreateRoomRequest(MatchExpression, ListString, RoomSettings, Room) |
Creates a new QuickJoinOrCreateRoomRequest instance.
|
void SomeMethod() { sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdd); 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); // Set the Room settings to create a new Room if a matching one is not found RoomSettings settings = new RoomSettings("NewRoom__" + new System.Random().Next()); settings.GroupId = "games"; settings.IsPublic = true; settings.IsGame = true; settings.MaxUsers = 10; settings.MinPlayersToStartGame = 2; // Set requirements to allow users find the Room (see match expression above) in Room Variables List<RoomVariable> roomVars = new List<RoomVariable>(); roomVars.Add(new SFSRoomVariable("type", "Darts")); roomVars.Add(new SFSRoomVariable("maxBet", 50)); settings.Variables = roomVars; // Search (or create) and join a public Room within the "games" Group sfs.Send(new QuickJoinOrCreateRoomRequest(exp, new List<string>(){"games"}, settings)); } void OnRoomAdd(BaseEvent evt) { Console.WriteLine("Room created: " + (Room)evt.Params["room"]); // .Net / Unity System.Diagnostics.Debug.WriteLine("Room created: " + (Room)evt.Params["room"]); // UWP } 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 }