ElectroServer 5 Client: C#
Electrotank.Electroserver5.Api.UpdateUserVariableRequest Class Reference

This request creates or updates a user variable. More...

Inheritance diagram for Electrotank.Electroserver5.Api.UpdateUserVariableRequest:
Electrotank.Electroserver5.Api.EsRequest Electrotank.Electroserver5.Api.EsMessage Electrotank.Electroserver5.Api.IThriftSerializable

Public Member Functions

 UpdateUserVariableRequest ()
 
 UpdateUserVariableRequest (TBase t)
 
override TBase ToThrift ()
 
override TBase NewThrift ()
 
override void FromThrift (TBase t_)
 

Properties

string Name [get, set]
 Name of the user variable. More...
 
EsObject Value [get, set]
 Value of the user variable. More...
 

Detailed Description

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;
        }
}

Constructor & Destructor Documentation

Electrotank.Electroserver5.Api.UpdateUserVariableRequest.UpdateUserVariableRequest ( )
Electrotank.Electroserver5.Api.UpdateUserVariableRequest.UpdateUserVariableRequest ( TBase  t)

Member Function Documentation

override void Electrotank.Electroserver5.Api.UpdateUserVariableRequest.FromThrift ( TBase  t_)
virtual
override TBase Electrotank.Electroserver5.Api.UpdateUserVariableRequest.NewThrift ( )
virtual
override TBase Electrotank.Electroserver5.Api.UpdateUserVariableRequest.ToThrift ( )
virtual

Property Documentation

string Electrotank.Electroserver5.Api.UpdateUserVariableRequest.Name
getset

Name of the user variable.

EsObject Electrotank.Electroserver5.Api.UpdateUserVariableRequest.Value
getset

Value of the user variable.