CreateSFSGameRequest Class |
Namespace: Sfs2X.Requests.Game
public class CreateSFSGameRequest : BaseRequest
The CreateSFSGameRequest type exposes the following members.
Name | Description | |
---|---|---|
CreateSFSGameRequest |
Creates a new CreateSFSGameRequest instance.
|
void SomeMethod() { sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomCreated); sfs.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnRoomError); // Prepare the settings for a public game SFSGameSettings settings = new SFSGameSettings("DartsGame"); settings.MaxUsers = 2; settings.MaxSpectators = 8; settings.IsPublic = true; settings.MinPlayersToStartGame = 2; settings.NotifyGameStarted = true; // Set the matching expression to filter users joining the Room settings.PlayerMatchExpression = new MatchExpression("bestScore", NumberMatch.GREATER_THAN, 100); // Set a Room Variable containing the description of the game List<RoomVariable> roomVars = new List<RoomVariable>(); roomVars.Add(new SFSRoomVariable("desc", "Darts game, public, bestScore > 100")); settings.variables = roomVars; // Create the game smartFox.Send( new CreateSFSGameRequest(settings) ); } void OnRoomCreated(BaseEvent evt) { Console.WriteLine("Room created: " + (Room)evt.Params["room"]); // .Net / Unity System.Diagnostics.Debug.WriteLine("Room created: " + (Room)evt.Params["room"]); // UWP } void OnRoomError(BaseEvent evt) { Console.WriteLine("Room creation failed: " + (string)evt.Params["errorMessage"]); // .Net / Unity System.Diagnostics.Debug.WriteLine("Room creation failed: " + (string)evt.Params["errorMessage"]); // UWP }