SetRoomVariablesRequest Class |
Namespace: Sfs2X.Requests
public class SetRoomVariablesRequest : BaseRequest
Name | Description | |
---|---|---|
SetRoomVariablesRequest(ICollectionRoomVariable) |
See SetRoomVariablesRequest(ICollection<RoomVariable>, Room) constructor.
| |
SetRoomVariablesRequest(ICollectionRoomVariable, Room) |
Creates a new SetRoomVariablesRequest instance.
|
void SomeMethod() { sfs.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, OnRoomVarsUpdate); // Create some Room Variables List<RoomVariable> roomVars = new List<RoomVariable>(); roomVars.Add( new SFSRoomVariable("gameStarted", false) ); roomVars.Add( new SFSRoomVariable("gameType", "Snooker") ); roomVars.Add( new SFSRoomVariable("minRank", 10) ); sfs.Send( new SetRoomVariablesRequest(roomVars) ); } void OnRoomVarsUpdate(BaseEvent evt) { List<String> changedVars = (List<String>)evt.Params["changedVars"]; Room room = (Room)evt.Params["room"]; // Check if the gameStarted variable was changed if (changedVars.Contains ("gameStarted")) { if (room.GetVariable("gameStarted").GetBoolValue()) { Console.WriteLine("Game started"); // .Net / Unity System.Diagnostics.Debug.WriteLine("Game started"); // UWP } else { Console.WriteLine("Game stopped"); // .Net / Unity System.Diagnostics.Debug.WriteLine("Game stopped"); // UWP } } }