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

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

Inheritance diagram for Electrotank.Electroserver5.Api.PluginMessageEvent:
Electrotank.Electroserver5.Api.EsEvent Electrotank.Electroserver5.Api.EsMessage Electrotank.Electroserver5.Api.IThriftSerializable

Public Member Functions

 PluginMessageEvent ()
 
 PluginMessageEvent (TBase t)
 
override TBase ToThrift ()
 
override TBase NewThrift ()
 
override void FromThrift (TBase t_)
 
- Public Member Functions inherited from Electrotank.Electroserver5.Api.EsEvent
 EsEvent ()
 

Properties

string PluginName [get, set]
 Name of the plugin instance that sent the message. More...
 
bool SentToRoom [get, set]
 If true then this message was sent to a room and not to the client directly. More...
 
int DestinationZoneId [get, set]
 If 'sentToRoom' is true then 'destinationZoneId' and 'destinationRoomId' contain the ids of the target zone and room. More...
 
int DestinationRoomId [get, set]
 If 'sentToRoom' is true then 'destinationZoneId' and 'destinationRoomId' contain the ids of the target zone and room. More...
 
bool RoomLevelPlugin [get, set]
 
int OriginZoneId [get, set]
 Id of the zone that contains the room (that contains the plugin), if the message originated from a room-level plugin. More...
 
int OriginRoomId [get, set]
 Id of the room that contains the plugin, if the message originated from a room-level plugin. More...
 
EsObject Parameters [get, set]
 All custom information that the plugin has sent to the client is contained in this EsObject. More...
 

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

Constructor & Destructor Documentation

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

Member Function Documentation

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

Property Documentation

int Electrotank.Electroserver5.Api.PluginMessageEvent.DestinationRoomId
getset

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

int Electrotank.Electroserver5.Api.PluginMessageEvent.DestinationZoneId
getset

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

int Electrotank.Electroserver5.Api.PluginMessageEvent.OriginRoomId
getset

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

int Electrotank.Electroserver5.Api.PluginMessageEvent.OriginZoneId
getset

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

EsObject Electrotank.Electroserver5.Api.PluginMessageEvent.Parameters
getset

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

string Electrotank.Electroserver5.Api.PluginMessageEvent.PluginName
getset

Name of the plugin instance that sent the message.

bool Electrotank.Electroserver5.Api.PluginMessageEvent.RoomLevelPlugin
getset
bool Electrotank.Electroserver5.Api.PluginMessageEvent.SentToRoom
getset

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