Torque3D Documentation / _generateds / scriptMsgListener.cpp

scriptMsgListener.cpp

Engine/source/util/messaging/scriptMsgListener.cpp

More...

Public Functions

ConsoleDoc("@class <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">ScriptMsgListener\n</a>" "@brief Script accessible version of Dispatcher::IMessageListener. Often used in conjunction with <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">EventManager\n\n</a>" "The <a href="/coding/file/x86unixmain_8cpp/#x86unixmain_8cpp_1a217dbf8b442f20279ea00b898af96f52">main</a> use of <a href="/coding/class/classscriptmsglistener/">ScriptMsgListener</a> is <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> allow script <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> listen <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a>" "messages. You can subclass <a href="/coding/class/classscriptmsglistener/">ScriptMsgListener</a> in script <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> receive" "the <a href="/coding/class/classdispatcher_1_1imessagelistener/">Dispatcher::IMessageListener</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">callbacks.\n\n</a>" " Alternatively, you can derive from it in C++instead of <a href="/coding/class/classsimobject/">SimObject</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a>" "get an object that implements <a href="/coding/class/classdispatcher_1_1imessagelistener/">Dispatcher::IMessageListener</a> with script" "callbacks. If you need <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> derive from something other then SimObject)
IMPLEMENT_CALLBACK(ScriptMsgListener , onAdd , void , () , () , "Script callback when a listener is first created and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">registered.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "function <a href="/coding/class/classscriptmsglistener/#classscriptmsglistener_1ae4831f6416b20c8915c41a0a46227d60">ScriptMsgListener::onAdd</a>(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "	// Perform on add code <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">here\n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
IMPLEMENT_CALLBACK(ScriptMsgListener , onAddToQueue , void , (const char *queue) , (queue) , "@brief Callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> when the listener is added <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">queue\n\n</a>" "The default implementation of onAddToQueue() and onRemoveFromQueue() " "provide tracking of the queues this listener is added <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> through the " "mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue() " "should ensure they call the parent implementation in any <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">overrides.\n</a>" "@param queue The name of the queue that the listener added <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to\n</a>" "@see onRemoveFromQueue()" )
IMPLEMENT_CALLBACK(ScriptMsgListener , onMessageObjectReceived , bool , (const char *queue, Message *msg) , (queue, msg) , "Called when a message object (not just the message data) is passed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">listener.\n</a>" "@param queue The name of the queue the message was dispatched <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to\n</a>" "@param msg The message <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">object\n</a>" "@return false <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> prevent other listeners receiving this message, true <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">otherwise\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Message\n</a>" " @see onMessageReceived" )
IMPLEMENT_CALLBACK(ScriptMsgListener , onMessageReceived , bool , (const char *queue, const char *event, const char *data) , (queue, event, data) , "Called when the listener has received a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">message.\n</a>" "@param queue The name of the queue the message was dispatched <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to\n</a>" "@param event The name of the event (function) that was <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">triggered\n</a>" "@param data The data (parameters) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">message\n\n</a>" "@return false <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> prevent other listeners receiving this message, true <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">otherwise\n</a>" )
IMPLEMENT_CALLBACK(ScriptMsgListener , onRemove , void , () , () , "Script callback when a listener is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">deleted.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "function <a href="/coding/class/classscriptmsglistener/#classscriptmsglistener_1a436be729c1ca5700f1829421950f82b9">ScriptMsgListener::onRemove</a>(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "	// Perform on remove code <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">here\n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
IMPLEMENT_CALLBACK(ScriptMsgListener , onRemoveFromQueue , void , (const char *queue) , (queue) , "@brief Callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> when the listener is removed from a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">queue\n\n</a>" "The default implementation of onAddToQueue() and onRemoveFromQueue() " "provide tracking of the queues this listener is added <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> through the " "mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue() " "should ensure they call the parent implementation in any <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">overrides.\n</a>" "@param queue The name of the queue that the listener was removed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from\n</a>" "@see onAddToQueue()" )

Callback for when the listener is removed from a queue.

Detailed Description

Public Functions

ConsoleDoc("@class <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">ScriptMsgListener\n</a>" "@brief Script accessible version of Dispatcher::IMessageListener. Often used in conjunction with <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">EventManager\n\n</a>" "The <a href="/coding/file/x86unixmain_8cpp/#x86unixmain_8cpp_1a217dbf8b442f20279ea00b898af96f52">main</a> use of <a href="/coding/class/classscriptmsglistener/">ScriptMsgListener</a> is <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> allow script <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> listen <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a>" "messages. You can subclass <a href="/coding/class/classscriptmsglistener/">ScriptMsgListener</a> in script <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> receive" "the <a href="/coding/class/classdispatcher_1_1imessagelistener/">Dispatcher::IMessageListener</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">callbacks.\n\n</a>" " Alternatively, you can derive from it in C++instead of <a href="/coding/class/classsimobject/">SimObject</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a>" "get an object that implements <a href="/coding/class/classdispatcher_1_1imessagelistener/">Dispatcher::IMessageListener</a> with script" "callbacks. If you need <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> derive from something other then SimObject)

IMPLEMENT_CALLBACK(ScriptMsgListener , onAdd , void , () , () , "Script callback when a listener is first created and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">registered.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "function <a href="/coding/class/classscriptmsglistener/#classscriptmsglistener_1ae4831f6416b20c8915c41a0a46227d60">ScriptMsgListener::onAdd</a>(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "	// Perform on add code <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">here\n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )

IMPLEMENT_CALLBACK(ScriptMsgListener , onAddToQueue , void , (const char *queue) , (queue) , "@brief Callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> when the listener is added <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">queue\n\n</a>" "The default implementation of onAddToQueue() and onRemoveFromQueue() " "provide tracking of the queues this listener is added <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> through the " "mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue() " "should ensure they call the parent implementation in any <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">overrides.\n</a>" "@param queue The name of the queue that the listener added <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to\n</a>" "@see onRemoveFromQueue()" )

IMPLEMENT_CALLBACK(ScriptMsgListener , onMessageObjectReceived , bool , (const char *queue, Message *msg) , (queue, msg) , "Called when a message object (not just the message data) is passed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">listener.\n</a>" "@param queue The name of the queue the message was dispatched <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to\n</a>" "@param msg The message <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">object\n</a>" "@return false <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> prevent other listeners receiving this message, true <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">otherwise\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Message\n</a>" " @see onMessageReceived" )

IMPLEMENT_CALLBACK(ScriptMsgListener , onMessageReceived , bool , (const char *queue, const char *event, const char *data) , (queue, event, data) , "Called when the listener has received a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">message.\n</a>" "@param queue The name of the queue the message was dispatched <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to\n</a>" "@param event The name of the event (function) that was <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">triggered\n</a>" "@param data The data (parameters) <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">message\n\n</a>" "@return false <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> prevent other listeners receiving this message, true <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">otherwise\n</a>" )

IMPLEMENT_CALLBACK(ScriptMsgListener , onRemove , void , () , () , "Script callback when a listener is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">deleted.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "function <a href="/coding/class/classscriptmsglistener/#classscriptmsglistener_1a436be729c1ca5700f1829421950f82b9">ScriptMsgListener::onRemove</a>(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "	// Perform on remove code <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">here\n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )

IMPLEMENT_CALLBACK(ScriptMsgListener , onRemoveFromQueue , void , (const char *queue) , (queue) , "@brief Callback <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> when the listener is removed from a <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">queue\n\n</a>" "The default implementation of onAddToQueue() and onRemoveFromQueue() " "provide tracking of the queues this listener is added <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> through the " "mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue() " "should ensure they call the parent implementation in any <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">overrides.\n</a>" "@param queue The name of the queue that the listener was removed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from\n</a>" "@see onAddToQueue()" )

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:

onAddToQueue()

IMPLEMENT_CONOBJECT(ScriptMsgListener )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "platform/platform.h"
 25#include "util/messaging/scriptMsgListener.h"
 26
 27#include "console/consoleTypes.h"
 28
 29#include "console/engineAPI.h"
 30
 31//-----------------------------------------------------------------------------
 32// Constructor
 33//-----------------------------------------------------------------------------
 34
 35ScriptMsgListener::ScriptMsgListener()
 36{
 37}
 38
 39IMPLEMENT_CONOBJECT(ScriptMsgListener);
 40
 41ConsoleDoc("@class ScriptMsgListener\n"
 42   "@brief Script accessible version of Dispatcher::IMessageListener. Often used in conjunction with EventManager\n\n"
 43
 44   "The main use of ScriptMsgListener is to allow script to listen for"
 45   "messages. You can subclass ScriptMsgListener in script to receive"
 46   "the Dispatcher::IMessageListener callbacks.\n\n"
 47
 48   "Alternatively, you can derive from it in C++ instead of SimObject to"
 49   "get an object that implements Dispatcher::IMessageListener with script"
 50   "callbacks. If you need to derive from something other then SimObject,"
 51   "then you will need to implement the Dispatcher::IMessageListener"
 52   "interface yourself.\n\n"
 53
 54   "@tsexample\n"
 55   "// Create the EventManager.\n"
 56   "$MyEventManager = new EventManager() { queue = \"MyEventManager\"; };\n\n"
 57   "// Create an event.\n"
 58   "$MyEventManager.registerEvent( \"SomeCoolEvent\" );\n\n"
 59   "// Create a listener and subscribe.\n"
 60   "$MyListener = new ScriptMsgListener() { class = MyListener; };\n"
 61   "$MyEventManager.subscribe( $MyListener, \"SomeCoolEvent\" );\n\n"
 62   "function MyListener::onSomeCoolEvent( %this, %data )\n"
 63   "{\n"
 64   "  echo( \"onSomeCoolEvent Triggered\" );\n"
 65   "}\n\n"
 66   "// Trigger the event.\n"
 67   "$MyEventManager.postEvent( \"SomeCoolEvent\", \"Data\" );\n"
 68   "@endtsexample\n\n"
 69
 70   "@ingroup Messaging\n"
 71);
 72
 73//-----------------------------------------------------------------------------
 74IMPLEMENT_CALLBACK(ScriptMsgListener, onAdd, void, (),(),
 75               "Script callback when a listener is first created and registered.\n\n"
 76               "@tsexample\n"
 77               "function ScriptMsgListener::onAdd(%this)\n"
 78               "{\n"
 79               "  // Perform on add code here\n"
 80               "}\n"
 81               "@endtsexample\n\n"
 82               );
 83
 84bool ScriptMsgListener::onAdd()
 85{
 86   if(! Parent::onAdd())
 87      return false;
 88
 89   linkNamespaces();
 90   onAdd_callback();
 91   //Con::executef(this, "onAdd");
 92   return true;
 93}
 94
 95IMPLEMENT_CALLBACK(ScriptMsgListener, onRemove, void, (),(),
 96               "Script callback when a listener is deleted.\n\n"
 97               "@tsexample\n"
 98               "function ScriptMsgListener::onRemove(%this)\n"
 99               "{\n"
100               "  // Perform on remove code here\n"
101               "}\n"
102               "@endtsexample\n\n"
103               );
104
105void ScriptMsgListener::onRemove()
106{
107   onRemove_callback();
108   //Con::executef(this, "onRemove");
109   unlinkNamespaces();
110   
111   Parent::onRemove();
112}
113
114//-----------------------------------------------------------------------------
115// Public Methods
116//-----------------------------------------------------------------------------
117IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageReceived, bool, ( const char* queue, const char* event, const char* data ), ( queue, event, data ),
118   "Called when the listener has received a message.\n"
119   "@param queue The name of the queue the message was dispatched to\n"
120   "@param event The name of the event (function) that was triggered\n"
121   "@param data The data (parameters) for the message\n\n"
122   "@return false to prevent other listeners receiving this message, true otherwise\n" );
123
124bool ScriptMsgListener::onMessageReceived(StringTableEntry queue, const char* event, const char* data)
125{
126   return onMessageReceived_callback(queue, event, data);
127   //return dAtob(Con::executef(this, "onMessageReceived", queue, event, data));
128}
129
130IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageObjectReceived, bool, ( const char* queue, Message *msg ), ( queue, msg ),
131   "Called when a message object (not just the message data) is passed to a listener.\n"
132   "@param queue The name of the queue the message was dispatched to\n"
133   "@param msg The message object\n"
134   "@return false to prevent other listeners receiving this message, true otherwise\n" 
135   "@see Message\n"
136   "@see onMessageReceived");
137
138bool ScriptMsgListener::onMessageObjectReceived(StringTableEntry queue, Message *msg)
139{
140   return onMessageObjectReceived_callback(queue, msg);
141   //return dAtob(Con::executef(this, "onMessageObjectReceived", queue, Con::getIntArg(msg->getId())));
142}
143
144//-----------------------------------------------------------------------------
145IMPLEMENT_CALLBACK( ScriptMsgListener, onAddToQueue, void, ( const char* queue), ( queue),
146   "@brief Callback for when the listener is added to a queue\n\n"
147   "The default implementation of onAddToQueue() and onRemoveFromQueue() "
148   "provide tracking of the queues this listener is added to through the "
149   "mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue() "
150   "should ensure they call the parent implementation in any overrides.\n"
151   "@param queue The name of the queue that the listener added to\n"
152      "@see onRemoveFromQueue()");
153
154void ScriptMsgListener::onAddToQueue(StringTableEntry queue)
155{
156   //Con::executef(this, "onAddToQueue", queue);
157   onAddToQueue_callback(queue);
158   IMLParent::onAddToQueue(queue);
159}
160
161/// @brief Callback for when the listener is removed from a queue
162   /// 
163   /// The default implementation of onAddToQueue() and onRemoveFromQueue()
164   /// provide tracking of the queues this listener is added to through the
165   /// #mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue()
166   /// should ensure they call the parent implementation in any overrides.
167   /// 
168   /// @param queue The name of the queue the listener was removed from
169   /// @see onAddToQueue()
170   //-----------------------------------------------------------------------------
171IMPLEMENT_CALLBACK( ScriptMsgListener, onRemoveFromQueue, void, ( const char* queue), ( queue),
172   "@brief Callback for when the listener is removed from a queue\n\n"
173   "The default implementation of onAddToQueue() and onRemoveFromQueue() "
174   "provide tracking of the queues this listener is added to through the "
175   "mQueues member. Overrides of onAddToQueue() or onRemoveFromQueue() "
176   "should ensure they call the parent implementation in any overrides.\n"
177   "@param queue The name of the queue that the listener was removed from\n"
178      "@see onAddToQueue()");
179
180void ScriptMsgListener::onRemoveFromQueue(StringTableEntry queue)
181{
182   //Con::executef(this, "onRemoveFromQueue", queue);
183   onRemoveFromQueue_callback(queue);
184   IMLParent::onRemoveFromQueue(queue);
185}
186