Torque3D Documentation / _generateds / messageForwarder.cpp

messageForwarder.cpp

Engine/source/util/messaging/messageForwarder.cpp

More...

Public Functions

ConsoleDocClass(MessageForwarder , "@brief Forward messages from one queue <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">another\n\n</a>" "<a href="/coding/class/classmessageforwarder/">MessageForwarder</a> is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> script class that can be used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> forward messages " "from one queue <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">another.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% fwd)

Detailed Description

Public Functions

ConsoleDocClass(MessageForwarder , "@brief Forward messages from one queue <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">another\n\n</a>" "<a href="/coding/class/classmessageforwarder/">MessageForwarder</a> is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> script class that can be used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> forward messages " "from one queue <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">another.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% fwd)

IMPLEMENT_CONOBJECT(MessageForwarder )

 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/messageForwarder.h"
26
27#include "console/consoleTypes.h"
28
29//-----------------------------------------------------------------------------
30// Constructor/Destructor
31//-----------------------------------------------------------------------------
32
33MessageForwarder::MessageForwarder()
34{
35   mToQueue = "";
36}
37
38MessageForwarder::~MessageForwarder()
39{
40}
41
42IMPLEMENT_CONOBJECT(MessageForwarder);
43
44ConsoleDocClass( MessageForwarder,
45   "@brief Forward messages from one queue to another\n\n"
46
47   "MessageForwarder is a script class that can be used to forward messages "
48   "from one queue to another.\n\n"
49   
50   "@tsexample\n"
51   "%fwd = new MessageForwarder()\n"
52   "{\n"
53   "  toQueue = \"QueueToSendTo\";\n"
54   "};\n\n"
55   "registerMessageListener(\"FromQueue\", %fwd);\n"
56   "@endtsexample\n\n"
57
58   "Where \"QueueToSendTo\" is the queue you want to forward to, and "
59   "\"FromQueue\" is the queue you want to forward from.\n\n"
60
61   "@ingroup Messaging\n"
62);
63
64//-----------------------------------------------------------------------------
65
66void MessageForwarder::initPersistFields()
67{
68   addField("toQueue", TypeCaseString, Offset(mToQueue, MessageForwarder), "Name of queue to forward to");
69
70   Parent::initPersistFields();
71}
72
73//-----------------------------------------------------------------------------
74// Public Methods
75//-----------------------------------------------------------------------------
76
77bool MessageForwarder::onMessageReceived(StringTableEntry queue, const char *event, const char *data)
78{
79   if(*mToQueue)
80      Dispatcher::dispatchMessage(queue, event, data);
81   return Parent::onMessageReceived(queue, event, data);
82}
83
84bool MessageForwarder::onMessageObjectReceived(StringTableEntry queue, Message *msg)
85{
86   if(*mToQueue)
87      Dispatcher::dispatchMessageObject(mToQueue, msg);
88   return Parent::onMessageObjectReceived(queue, msg);
89}
90