Packagecom.electrotank.electroserver5.api
Classpublic class CreateRoomVariableRequest
InheritanceCreateRoomVariableRequest Inheritance EsRequest Inheritance EsMessage Inheritance flash.events.Event

This request creates a room variable. A room variable is a name/value pair scoped to a room and managed on the server. The value is an EsObject. Room variables are accessible via the client also. A room variable can be created, updated, or removed by a client or by a server extension. In addition to the name and value a room variable has two other properties: locked and persistent, both booleans. If locked is true then the variable cannot be modified until unlocked. If persistent is true then the variable stays alive until manually deleted or the room dies. If persistent is false then the variable dies when the user that creates it leaves the room, or if it is manually removed. In addition to being created by this request, room variables can also be created (and modified) by the server or created during the creation of the room using the CreateRoomRequest. This shows how to create a room variable and watch for the RoomVariableUpdateEvent.
private var _es:ElectroServer;
private function initialize():void {
        _es.engine.addEventListener(MessageType.RoomVariableUpdateEvent.name, onRoomVariableUpdateEvent);
        testCreateRoomVariable();
}
private function testCreateRoomVariable():void {
        //create the request object and populate with data
        var crvr:CreateRoomVariableRequest = new CreateRoomVariableRequest();
        crvr.name = "background";
        crvr.value = new EsObject();
        crvr.value.setString("music", "pop.mp3");
        crvr.value.setString("color", "blue");
        //send it
        _es.engine.send(crvr);
}
private function onRoomVariableUpdateEvent(e:RoomVariableUpdateEvent):void {
        var room:Room = _es.managerHelper.zoneManager.zoneById(e.zoneId).roomById(e.roomId);
        var roomVar:RoomVariable;
        switch (e.action) {
                case RoomVariableUpdateAction.VariableCreated:
                        //the variable is already being managed in the room, so grab it
                        roomVar = room.roomVariableByName(e.name);
                        trace("Room variable created. Name: " + roomVar.name + ", value: " + roomVar.value.toString());
                        break;
                case RoomVariableUpdateAction.VariableDeleted:
                        //the variable has already been deleted in the room, so for its name inspect the event object
                        trace("Room variable deleted. Name: " + e.name);
                        break;
                case RoomVariableUpdateAction.VariableUpdated:
                        //the variable is being managed in the room, so grab it
                        roomVar = room.roomVariableByName(e.name);
                        trace("Room variable updated. Name: " + roomVar.name + ", value: " + roomVar.value.toString());
                        break;
        }
}



Public Properties
 PropertyDefined By
  locked : Boolean
The locked value of the room variable.
CreateRoomVariableRequest
 InheritedmessageNumber : int
EsMessage
 InheritedmessageType : MessageType
EsMessage
  name : String
Name of the room variable.
CreateRoomVariableRequest
  persistent : Boolean
If true then the variable is only removed when manually deleted or when the room itself is removed.
CreateRoomVariableRequest
 InheritedrequestId : int
EsMessage
  roomId : int
Id of the room that contains the room variable.
CreateRoomVariableRequest
 InheritedserverId : String
EsMessage
  value : EsObject
Value of the room variable.
CreateRoomVariableRequest
  zoneId : int
Id of the zone that contains the room.
CreateRoomVariableRequest
Public Methods
 MethodDefined By
  
CreateRoomVariableRequest(m:MessageType = null, t:TBase = null)
CreateRoomVariableRequest
  
fromThrift(t_:TBase):void
[override]
CreateRoomVariableRequest
  
newThrift():TBase
[override]
CreateRoomVariableRequest
  
toThrift():TBase
[override]
CreateRoomVariableRequest
Property Detail
lockedproperty
locked:Boolean

The locked value of the room variable. If locked the room variable cannot be modified until unlocked. It's cleanup behavior is unchanged.


Implementation
    public function get locked():Boolean
    public function set locked(value:Boolean):void
nameproperty 
name:String

Name of the room variable.


Implementation
    public function get name():String
    public function set name(value:String):void
persistentproperty 
persistent:Boolean

If true then the variable is only removed when manually deleted or when the room itself is removed. If false then the room variable is automatically removed when the user that crated it leaves the room.


Implementation
    public function get persistent():Boolean
    public function set persistent(value:Boolean):void
roomIdproperty 
roomId:int

Id of the room that contains the room variable.


Implementation
    public function get roomId():int
    public function set roomId(value:int):void
valueproperty 
value:EsObject

Value of the room variable.


Implementation
    public function get value():EsObject
    public function set value(value:EsObject):void
zoneIdproperty 
zoneId:int

Id of the zone that contains the room.


Implementation
    public function get zoneId():int
    public function set zoneId(value:int):void
Constructor Detail
CreateRoomVariableRequest()Constructor
public function CreateRoomVariableRequest(m:MessageType = null, t:TBase = null)



Parameters
m:MessageType (default = null)
 
t:TBase (default = null)
Method Detail
fromThrift()method
override public function fromThrift(t_:TBase):void

Parameters

t_:TBase

newThrift()method 
override public function newThrift():TBase

Returns
TBase
toThrift()method 
override public function toThrift():TBase

Returns
TBase