ElectroServer 5 Client: Cocoa-Touch
EsRoomVariableUpdateEvent Class Reference

When a room variable is created, deleted, or updated in a room that the client belongs to then this event occurs. More...

Inheritance diagram for EsRoomVariableUpdateEvent:
EsEvent EsMessage EsEventDispatcherEvent

Instance Methods

(id) - init
 
(id) - initWithThriftObject:
 
(void) - fromThrift:
 
(ThriftRoomVariableUpdateEvent *) - toThrift
 
(id) - newThrift
 

Properties

int32_t zoneId
 Id of the zone that contains the room. More...
 
int32_t roomId
 Id of the room that contains the room variables. More...
 
NSString * name
 Name of the room variable. More...
 
BOOL valueChanged
 True if the value changed, false if not. More...
 
EsObjectvalue
 The value of the room variable, if this is a create action or if the value changed. More...
 
BOOL persistent
 If true then the variable is only removed when manually deleted or when the room itself is removed. More...
 
BOOL lockStatusChanged
 True if the value of the locked property changed. More...
 
BOOL locked
 The locked value of the room variable. More...
 
int action
 The action that describes what kind of an update this is: create, delete, or update. More...
 

Additional Inherited Members

- Protected Attributes inherited from EsMessage
int messageType_
 

Detailed Description

When a room variable is created, deleted, or updated in a room that the client belongs to then this event occurs.

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.

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

Method Documentation

- (void) fromThrift: (id)  thriftObject

Reimplemented from EsMessage.

- (id) init
- (id) initWithThriftObject: (id)  thriftObject
- (id) newThrift

Reimplemented from EsMessage.

- (ThriftRoomVariableUpdateEvent *) toThrift

Reimplemented from EsMessage.

Property Documentation

- (int) action
readwritenonatomicassign

The action that describes what kind of an update this is: create, delete, or update.

- (BOOL) locked
readwritenonatomicassign

The locked value of the room variable.

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

- (BOOL) lockStatusChanged
readwritenonatomicassign

True if the value of the locked property changed.

- (NSString*) name
readwritenonatomicretain

Name of the room variable.

- (BOOL) persistent
readwritenonatomicassign

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.

- (int32_t) roomId
readwritenonatomicassign

Id of the room that contains the room variables.

- (EsObject*) value
readwritenonatomicretain

The value of the room variable, if this is a create action or if the value changed.

- (BOOL) valueChanged
readwritenonatomicassign

True if the value changed, false if not.

- (int32_t) zoneId
readwritenonatomicassign

Id of the zone that contains the room.