summaryrefslogtreecommitdiff
path: root/indra/llmessage/llareslistener.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2009-06-19 00:17:30 +0000
committerNat Goodspeed <nat@lindenlab.com>2009-06-19 00:17:30 +0000
commitdc3833f31b8a20220ddb1775e1625c016c397435 (patch)
tree166ce57be2578ea03d1e20976977e4ca6c1f1dba /indra/llmessage/llareslistener.cpp
parent8a8edfd98c7fced23f4c1f8dd5e4f65e1cadfce8 (diff)
DEV-31980: extract dispatch-by-string-name logic from LLAresListener to new
LLEventDispatcher and LLDispatchListener classes. See LLAresListener for example usage.
Diffstat (limited to 'indra/llmessage/llareslistener.cpp')
-rw-r--r--indra/llmessage/llareslistener.cpp46
1 files changed, 6 insertions, 40 deletions
diff --git a/indra/llmessage/llareslistener.cpp b/indra/llmessage/llareslistener.cpp
index 4bf375069d..a8beb8cbde 100644
--- a/indra/llmessage/llareslistener.cpp
+++ b/indra/llmessage/llareslistener.cpp
@@ -9,10 +9,6 @@
* $/LicenseInfo$
*/
-#if LL_WINDOWS
-#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally
-#endif
-
// Precompiled header
#include "linden_common.h"
// associated header
@@ -27,35 +23,13 @@
#include "llsdutil.h"
LLAresListener::LLAresListener(const std::string& pumpname, LLAres* llares):
- mAres(llares),
- mBoundListener(LLEventPumps::instance().
- obtain(pumpname).
- listen("LLAresListener", boost::bind(&LLAresListener::process, this, _1)))
-{
- // Insert an entry into our mDispatch map for every method we want to be
- // able to invoke via this event API.
- mDispatch["rewriteURI"] = boost::bind(&LLAresListener::rewriteURI, this, _1);
-}
-
-bool LLAresListener::process(const LLSD& command)
+ LLDispatchListener(pumpname, "op"),
+ mAres(llares)
{
- const std::string op(command["op"]);
- // Look up the requested operation.
- DispatchMap::const_iterator found = mDispatch.find(op);
- if (found == mDispatch.end())
- {
- // There's no feedback other than our own reply. If somebody asks
- // for an operation that's not supported (perhaps because of a
- // typo?), unless we holler loudly, the request will be silently
- // ignored. Throwing a tantrum on such errors will hopefully make
- // this product more robust.
- LL_ERRS("LLAresListener") << "Unsupported request " << op << LL_ENDL;
- return false;
- }
- // Having found the operation, call it.
- found->second(command);
- // Conventional LLEventPump listener return
- return false;
+ // add() every method we want to be able to invoke via this event API.
+ // Optional third parameter validates expected LLSD request structure.
+ add("rewriteURI", &LLAresListener::rewriteURI,
+ LLSD().insert("uri", LLSD()).insert("reply", LLSD()));
}
/// This UriRewriteResponder subclass packages returned URIs as an LLSD
@@ -97,13 +71,5 @@ private:
void LLAresListener::rewriteURI(const LLSD& data)
{
- static LLSD required(LLSD().insert("uri", LLSD()).insert("reply", LLSD()));
- // Validate that the request is well-formed
- std::string mismatch(llsd_matches(required, data));
- if (! mismatch.empty())
- {
- LL_ERRS("LLAresListener") << "bad rewriteURI request: " << mismatch << LL_ENDL;
- }
- // Looks as though we have what we need; issue the request
mAres->rewriteURI(data["uri"], new UriRewriteResponder(data));
}