| Package | com.electrotank.electroserver4.message.request |
| Class | public class UpdateUserVariableRequest |
| Inheritance | UpdateUserVariableRequest com.electrotank.electroserver4.message.request.RequestImpl |
import com.electrotank.electroserver4.ElectroServer;
import com.electrotank.electroserver4.entities.UserVariable;
import com.electrotank.electroserver4.esobject.EsObject;
import com.electrotank.electroserver4.message.event.UserVariableUpdateEvent;
import com.electrotank.electroserver4.message.MessageType;
import com.electrotank.electroserver4.message.request.UpdateUserVariableRequest;
import com.electrotank.electroserver4.user.User;
var es:ElectroServer;//Assume a connection was created elsewhere and you're logged in.
function init():void {
es.addEventListener(MessageType.UserVariableUpdateEvent, "onUserVariableUpdatedEvent", this);
}
function createAndUpdateUserVariable():void {
//create the var
var uuvr:UpdateUserVariableRequest = new UpdateUserVariableRequest();
uuvr.setName("Test");
var esob:EsObject = new EsObject();
esob.setString("TestVar", "hello there");
uuvr.setValue(esob);
//send it
es.send(uuvr);
/////////////
//update the var
//
uuvr = new UpdateUserVariableRequest();
uuvr.setName("Test");
esob = new EsObject();
esob.setString("TestVar", "i said hello!");
//send it
es.send(uuvr);
}
function onUserVariableUpdatedEvent(e:UserVariableUpdateEvent):void {
var u:User = e.user;
var name:String = e.getVariableName();
trace("User variable name: "+name);
switch (e.getActionId()) {
case UserVariableUpdateEvent.VariableCreated:
var uv:UserVariable = u.getUserVariable(name);
trace("User variable created");
trace("User variable value: "+uv.getValue().getString("Test"));
break;
case UserVariableUpdateEvent.VariableUpdated:
var uv:UserVariable = u.getUserVariable(name);
trace("User variable updated.");
trace("User variable value: "+uv.getValue().getString("Test"));
break;
case UserVariableUpdateEvent.VariableDeleted:
trace("User variable deleted.");
break;
default:
trace("Update action not handled: "+e.getActionId());
break;
}
}
init();
createAndUpdateUserVariable();
| Method | Defined by | ||
|---|---|---|---|
|
Creates a new instance of the UpdateUserVariableRequest.
| UpdateUserVariableRequest | ||
|
getName():String
Gets the name of the variable to create or udpate.
| UpdateUserVariableRequest | ||
|
Gets the value of the variable.
| UpdateUserVariableRequest | ||
|
setName(name:String):void
Sets the name of the variable to create or update.
| UpdateUserVariableRequest | ||
|
Sets the value of the variable.
| UpdateUserVariableRequest | ||
| UpdateUserVariableRequest | |||
| UpdateUserVariableRequest | () | constructor |
public function UpdateUserVariableRequest()Creates a new instance of the UpdateUserVariableRequest.
| getName | () | method |
public function getName():StringGets the name of the variable to create or udpate.
ReturnsString — The name of the variable to create or udpate.
|
| getValue | () | method |
public function getValue():EsObjectGets the value of the variable.
ReturnsEsObject —
The value of the variable.
|
| setName | () | method |
public function setName(name:String):voidSets the name of the variable to create or update.
Parametersname:String — The name of the variable to create or udpate.
|
| setValue | () | method |
public function setValue(value:EsObject):voidSets the value of the variable.
Parametersvalue:EsObject — The value of the variable.
|
| validate | () | method |