Packagecom.electrotank.electroserver5.api
Classpublic class UpdateUserVariableRequest
InheritanceUpdateUserVariableRequest Inheritance EsRequest Inheritance EsMessage Inheritance flash.events.Event

This request creates or updates a user variable. A user variable is a name/value pair scoped to a user and store in the server. A user can see his/her own user variables, and can see the user variables for all people in the same room as them. The value is an EsObject. In addition to creating a user variable with this request, user variables can be created during the login process (see LoginRequest) or by the server. A user variable is deleted using the DeleteUserVariableRequest. This shows how to create a user variable and capture the update event.
private var _es:ElectroServer;
private function initialize():void {
        _es.engine.addEventListener(MessageType.UserVariableUpdateEvent.name, onUserVariableUpdateEvent);
        testCreateUserVariable();
}
private function testCreateUserVariable():void {
        //create the request and populate it with info
        var uuvr:UpdateUserVariableRequest = new UpdateUserVariableRequest();
        uuvr.name = "myDescription";
        uuvr.value = new EsObject();
        uuvr.value.setString("hairColor", "brown");
        uuvr.value.setInteger("age", 35);
        //send to the server
        _es.engine.send(uuvr);
}
private function onUserVariableUpdateEvent(e:UserVariableUpdateEvent):void {
        var userVar:UserVariable;
        switch (e.action) {
                case UserVariableUpdateAction.VariableCreated:
                        //the user variable is managed, so grab it
                        userVar = _es.managerHelper.userManager.me.userVariableByName(e.variable.name);
                        trace("User variable created. Name: " + userVar.name + ", value: " + userVar.value.toString());
                        break;
                case UserVariableUpdateAction.VariableDeleted:
                        //the user variable has already been deleted, so to see its name inspect the event object
                        trace("User variable deleted. Name: " + e.variable.name);
                        break;
                case UserVariableUpdateAction.VariableUpdated:
                        //the user variable is managed, so grab it
                        userVar = _es.managerHelper.userManager.me.userVariableByName(e.variable.name);
                        trace("User variable updated. Name: " + userVar.name + ", value: " + userVar.value.toString());
                        break;
        }
}



Public Properties
 PropertyDefined By
 InheritedmessageNumber : int
EsMessage
 InheritedmessageType : MessageType
EsMessage
  name : String
Name of the user variable
UpdateUserVariableRequest
 InheritedrequestId : int
EsMessage
 InheritedserverId : String
EsMessage
  value : EsObject
Value of the user variable.
UpdateUserVariableRequest
Public Methods
 MethodDefined By
  
UpdateUserVariableRequest(m:MessageType = null, t:TBase = null)
UpdateUserVariableRequest
  
fromThrift(t_:TBase):void
[override]
UpdateUserVariableRequest
  
newThrift():TBase
[override]
UpdateUserVariableRequest
  
toThrift():TBase
[override]
UpdateUserVariableRequest
Property Detail
nameproperty
name:String

Name of the user variable


Implementation
    public function get name():String
    public function set name(value:String):void
valueproperty 
value:EsObject

Value of the user variable.


Implementation
    public function get value():EsObject
    public function set value(value:EsObject):void
Constructor Detail
UpdateUserVariableRequest()Constructor
public function UpdateUserVariableRequest(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