summaryrefslogtreecommitdiff
path: root/indra/llcommon/llleaplistener.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llleaplistener.cpp')
-rw-r--r--indra/llcommon/llleaplistener.cpp58
1 files changed, 18 insertions, 40 deletions
diff --git a/indra/llcommon/llleaplistener.cpp b/indra/llcommon/llleaplistener.cpp
index fa5730f112..3e6ce9092c 100644
--- a/indra/llcommon/llleaplistener.cpp
+++ b/indra/llcommon/llleaplistener.cpp
@@ -14,6 +14,8 @@
// associated header
#include "llleaplistener.h"
// STL headers
+#include <map>
+#include <functional>
// std headers
// external library headers
#include <boost/foreach.hpp>
@@ -60,16 +62,11 @@ LLLeapListener::LLLeapListener(const ConnectFunc& connect):
LLSD need_name(LLSDMap("name", LLSD()));
add("newpump",
"Instantiate a new LLEventPump named like [\"name\"] and listen to it.\n"
- "If [\"type\"] == \"LLEventQueue\", make LLEventQueue, else LLEventStream.\n"
+ "[\"type\"] == \"LLEventStream\", \"LLEventMailDrop\" et al.\n"
"Events sent through new LLEventPump will be decorated with [\"pump\"]=name.\n"
"Returns actual name in [\"name\"] (may be different if collision).",
&LLLeapListener::newpump,
need_name);
- add("killpump",
- "Delete LLEventPump [\"name\"] created by \"newpump\".\n"
- "Returns [\"status\"] boolean indicating whether such a pump existed.",
- &LLLeapListener::killpump,
- need_name);
LLSD need_source_listener(LLSDMap("source", LLSD())("listener", LLSD()));
add("listen",
"Listen to an existing LLEventPump named [\"source\"], with listener name\n"
@@ -124,40 +121,23 @@ void LLLeapListener::newpump(const LLSD& request)
Response reply(LLSD(), request);
std::string name = request["name"];
- LLSD const & type = request["type"];
+ std::string type = request["type"];
- LLEventPump * new_pump = NULL;
- if (type.asString() == "LLEventQueue")
+ try
{
- new_pump = new LLEventQueue(name, true); // tweak name for uniqueness
+ // tweak name for uniqueness
+ LLEventPump& new_pump(LLEventPumps::instance().make(name, true, type));
+ name = new_pump.getName();
+ reply["name"] = name;
+
+ // Now listen on this new pump with our plugin listener
+ std::string myname("llleap");
+ saveListener(name, myname, mConnect(new_pump, myname));
}
- else
+ catch (const LLEventPumps::BadType& error)
{
- if (! (type.isUndefined() || type.asString() == "LLEventStream"))
- {
- reply.warn(STRINGIZE("unknown 'type' " << type << ", using LLEventStream"));
- }
- new_pump = new LLEventStream(name, true); // tweak name for uniqueness
+ reply.error(error.what());
}
-
- name = new_pump->getName();
-
- mEventPumps.insert(name, new_pump);
-
- // Now listen on this new pump with our plugin listener
- std::string myname("llleap");
- saveListener(name, myname, mConnect(*new_pump, myname));
-
- reply["name"] = name;
-}
-
-void LLLeapListener::killpump(const LLSD& request)
-{
- Response reply(LLSD(), request);
-
- std::string name = request["name"];
- // success == (nonzero number of entries were erased)
- reply["status"] = bool(mEventPumps.erase(name));
}
void LLLeapListener::listen(const LLSD& request)
@@ -228,13 +208,11 @@ void LLLeapListener::getAPIs(const LLSD& request) const
{
Response reply(LLSD(), request);
- for (LLEventAPI::instance_iter eai(LLEventAPI::beginInstances()),
- eaend(LLEventAPI::endInstances());
- eai != eaend; ++eai)
+ for (auto& ea : LLEventAPI::instance_snapshot())
{
LLSD info;
- info["desc"] = eai->getDesc();
- reply[eai->getName()] = info;
+ info["desc"] = ea.getDesc();
+ reply[ea.getName()] = info;
}
}