ElectroServer 5 Client: Cocoa-Touch
EsPluginMessageEvent Class Reference

This even occurs when a message from a plugin is received. More...

Inheritance diagram for EsPluginMessageEvent:
EsEvent EsMessage EsEventDispatcherEvent

Instance Methods

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

Properties

NSString * pluginName
 Name of the plugin instance that sent the message. More...
 
BOOL sentToRoom
 If true then this message was sent to a room and not to the client directly. More...
 
int32_t destinationZoneId
 If 'sentToRoom' is true then 'destinationZoneId' and 'destinationRoomId' contain the ids of the target zone and room. More...
 
int32_t destinationRoomId
 If 'sentToRoom' is true then 'destinationZoneId' and 'destinationRoomId' contain the ids of the target zone and room. More...
 
BOOL roomLevelPlugin
 
int32_t originZoneId
 Id of the zone that contains the room (that contains the plugin), if the message originated from a room-level plugin. More...
 
int32_t originRoomId
 Id of the room that contains the plugin, if the message originated from a room-level plugin. More...
 
EsObjectparameters
 All custom information that the plugin has sent to the client is contained in this EsObject. More...
 

Additional Inherited Members

- Protected Attributes inherited from EsMessage
int messageType_
 

Detailed Description

This even occurs when a message from a plugin is received.

That message could have been sent to a room that the client is in, or sent directly to that client. It could have originated from a plugin in a room that the client is in, or from a plugin in a room that the client is not in, or from a server-level plugin. There is enough information on the event object to determine the origin of the message.

In most cases all you care about is the pluginName (to give you some context about where the message came from) and the 'parameters' EsObject property which contains the custom information that the plugin wanted you to know abut.

This shows how to send a message to a room-level plugin, and how to capture a plugin message event when one is received.

private var _es:ElectroServer;
private var _room:Room;
private function initialize():void {
        _es.engine.addEventListener(MessageType.PluginMessageEvent.name, onPluginMessageEvent);
}
private function sendTestMessage():void {
        var ipr:InvokePluginRequest = new InvokePluginRequest();
        ipr.roomId = _room.id;
        ipr.zoneId = _room.zoneId;
        ipr.pluginName = "TankGame";
        ipr.parameters = new EsObject();
        ipr.parameters.setString("action", "shoot");
        ipr.parameters.setInteger("angle", 45);
        _es.engine.send(ipr);
}
private function onPluginMessageEvent(e:PluginMessageEvent):void {
        trace("plugin message event received");
        trace(e.pluginName);
        trace(e.parameters.getString("action"));
}

Method Documentation

- (void) fromThrift: (id)  thriftObject

Reimplemented from EsMessage.

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

Reimplemented from EsMessage.

- (ThriftPluginMessageEvent *) toThrift

Reimplemented from EsMessage.

Property Documentation

- (int32_t) destinationRoomId
readwritenonatomicassign

If 'sentToRoom' is true then 'destinationZoneId' and 'destinationRoomId' contain the ids of the target zone and room.

- (int32_t) destinationZoneId
readwritenonatomicassign

If 'sentToRoom' is true then 'destinationZoneId' and 'destinationRoomId' contain the ids of the target zone and room.

- (int32_t) originRoomId
readwritenonatomicassign

Id of the room that contains the plugin, if the message originated from a room-level plugin.

- (int32_t) originZoneId
readwritenonatomicassign

Id of the zone that contains the room (that contains the plugin), if the message originated from a room-level plugin.

- (EsObject*) parameters
readwritenonatomicretain

All custom information that the plugin has sent to the client is contained in this EsObject.

- (NSString*) pluginName
readwritenonatomicretain

Name of the plugin instance that sent the message.

- (BOOL) roomLevelPlugin
readwritenonatomicassign
- (BOOL) sentToRoom
readwritenonatomicassign

If true then this message was sent to a room and not to the client directly.