ScriptMsgListener Class Reference [Message System]

#include <scriptMsgListener.h>

Inheritance diagram for ScriptMsgListener:

Inheritance graph
[legend]
List of all members.

Detailed Description

Script accessible version of Dispatcher::IMessageListener.

The main use of ScriptMsgListener is to allow script to listen for messages. You can subclass ScriptMsgListener in script to receive the Dispatcher::IMessageListener callbacks.

Alternatively, you can derive from it in C++ instead of SimObject to get an object that implements Dispatcher::IMessageListener with script callbacks. If you need to derive from something other then SimObject, then you will need to implement the Dispatcher::IMessageListener interface yourself.


Public Member Functions

 ScriptMsgListener ()
 DECLARE_CONOBJECT (ScriptMsgListener)
virtual bool onAdd ()
 Called when the object is added to the sim.
virtual void onRemove ()
 Called when the object is removed from the sim.
virtual bool onMessageReceived (StringTableEntry queue, const char *event, const char *data)
 Callback for when messages are received.
virtual bool onMessageObjectReceived (StringTableEntry queue, Message *msg)
 Callback for when message objects are received.
virtual void onAddToQueue (StringTableEntry queue)
 Callback for when the listener is added to a queue.
virtual void onRemoveFromQueue (StringTableEntry queue)
 Callback for when the listener is removed from a queue.

Private Types

typedef SimObject Parent
typedef Dispatcher::IMessageListener IMLParent


Member Typedef Documentation

Reimplemented from SimObject.

Reimplemented in MessageForwarder.


Constructor & Destructor Documentation

ScriptMsgListener::ScriptMsgListener (  ) 


Member Function Documentation

ScriptMsgListener::DECLARE_CONOBJECT ( ScriptMsgListener   ) 

virtual bool ScriptMsgListener::onAdd (  )  [virtual]

Called when the object is added to the sim.

Reimplemented from SimObject.

virtual void ScriptMsgListener::onRemove (  )  [virtual]

Called when the object is removed from the sim.

Reimplemented from SimObject.

virtual bool ScriptMsgListener::onMessageReceived ( StringTableEntry  queue,
const char *  event,
const char *  data 
) [virtual]

Callback for when messages are received.

Parameters:
queue The name of the queue the message was dispatched to
msg The type of message
data The data for the message
Returns:
false to prevent other listeners receiving this message, true otherwise
See also:
onMessageObjectReceived()

Implements Dispatcher::IMessageListener.

Reimplemented in MessageForwarder.

virtual bool ScriptMsgListener::onMessageObjectReceived ( StringTableEntry  queue,
Message msg 
) [virtual]

Callback for when message objects are received.

Parameters:
queue The name of the queue the message was dispatched to
msg The message object
Returns:
false to prevent other listeners receiving this message, true otherwise
See also:
onMessageReceived()

Implements Dispatcher::IMessageListener.

Reimplemented in MessageForwarder.

virtual void ScriptMsgListener::onAddToQueue ( StringTableEntry  queue  )  [virtual]

Callback for when the listener is added to a queue.

The default implementation of onAddToQueue() and onRemoveFromQueue() provide tracking of the queues this listener is added to through the mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue() should ensure they call the parent implementation in any overrides.

Parameters:
queue The name of the queue that the listener added to
See also:
onRemoveFromQueue()

Reimplemented from Dispatcher::IMessageListener.

virtual void ScriptMsgListener::onRemoveFromQueue ( StringTableEntry  queue  )  [virtual]

Callback for when the listener is removed from a queue.

The default implementation of onAddToQueue() and onRemoveFromQueue() provide tracking of the queues this listener is added to through the mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue() should ensure they call the parent implementation in any overrides.

Parameters:
queue The name of the queue the listener was removed from
See also:
onAddToQueue()

Reimplemented from Dispatcher::IMessageListener.