Package | com.smartfoxserver.v2.requests |
Class | public class SetRoomVariablesRequest |
Inheritance | SetRoomVariablesRequest com.smartfoxserver.v2.requests.BaseRequest |
When a Room Variable is set, the roomVariablesUpdate event is dispatched to all the users in the target Room, including the user who updated it. Also, if the Room Variable is global (see the SFSRoomVariable class description), the event is dispatched to all users who subscribed the Group to which the target Room is associated.
See also
Method | Defined By | ||
---|---|---|---|
SetRoomVariablesRequest(roomVariables:Array, room:Room = null)
Creates a new SetRoomVariablesRequest instance. | SetRoomVariablesRequest |
SetRoomVariablesRequest | () | Constructor |
public function SetRoomVariablesRequest(roomVariables:Array, room:Room = null)
Creates a new SetRoomVariablesRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
ParametersroomVariables:Array — A list of RoomVariable objects representing the Room Variables to be set.
| |
room:Room (default = null ) — A Room object representing the Room where to set the Room Variables; if null , the last Room joined by the current user is used.
|
See also
private function someMethod():void { sfs.addEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, onRoomVarsUpdate); // Create some Room Variables var roomVars:Array = []; roomVars.push(new SFSRoomVariable("gameStarted", false)); roomVars.push(new SFSRoomVariable("gameType", "Snooker")); roomVars.push(new SFSRoomVariable("minRank", 10)); sfs.send(new SetRoomVariablesRequest(roomVars)); } private function onRoomVarsUpdate(evt:SFSEvent):void { var changedVars:Array = evt.params.changedVars as Array; var room:Room = evt.params.room as Room; // Check if the "gameStarted" variable was changed if (changedVars.indexOf("gameStarted") != -1) { if (room.getVariable("gameStarted").getBoolValue() == true) trace("Game started"); else trace("Game stopped"); } }