diff options
author | Rider Linden <rider@lindenlab.com> | 2015-09-02 11:50:26 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2015-09-02 11:50:26 -0700 |
commit | 6c9610b4e44020bf266a5da7375fb9f2b24f4f8a (patch) | |
tree | baf73d9f0c948149dfee20d850904bed0f01f27c /indra/llmessage/llexperiencecache.cpp | |
parent | c5dc9b1a572f00e69b9cd3b5853f0a3d104af20f (diff) |
Move associated experience fetching into the ExperienceCache as a coro remove the responder.
Diffstat (limited to 'indra/llmessage/llexperiencecache.cpp')
-rw-r--r-- | indra/llmessage/llexperiencecache.cpp | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp index 36a4fc8823..b65a3c59d5 100644 --- a/indra/llmessage/llexperiencecache.cpp +++ b/indra/llmessage/llexperiencecache.cpp @@ -356,7 +356,7 @@ void LLExperienceCache::requestExperiences() if (mRequestQueue.empty() || (ostr.tellp() > EXP_URL_SEND_THRESHOLD)) { // request is placed in the coprocedure pool for the ExpCache cache. Throttling is done by the pool itself. - LLCoprocedureManager::getInstance()->enqueueCoprocedure("ExpCache", "Request", + LLCoprocedureManager::getInstance()->enqueueCoprocedure("ExpCache", "RequestExperiences", boost::bind(&LLExperienceCache::requestExperiencesCoro, this, _1, ostr.str(), requests) ); ostr.str(std::string()); @@ -506,7 +506,8 @@ const LLSD& LLExperienceCache::get(const LLUUID& key) return empty; } -void LLExperienceCache::get(const LLUUID& key, LLExperienceCache::Callback_t slot) + +void LLExperienceCache::get(const LLUUID& key, LLExperienceCache::ExperienceGetFn_t slot) { if(key.isNull()) return; @@ -533,6 +534,64 @@ void LLExperienceCache::get(const LLUUID& key, LLExperienceCache::Callback_t slo } //========================================================================= +void LLExperienceCache::fetchAssociatedExperience(const LLUUID& objectId, const LLUUID& itemId, ExperienceGetFn_t fn) +{ + if (mCapability.empty()) + { + LL_WARNS("ExperienceCache") << "Capability query method not set." << LL_ENDL; + return; + } + + LLCoprocedureManager::getInstance()->enqueueCoprocedure("ExpCache", "Fetch Associated", + boost::bind(&LLExperienceCache::fetchAssociatedExperienceCoro, this, _1, objectId, itemId, fn)); +} + +void LLExperienceCache::fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, LLUUID objectId, LLUUID itemId, ExperienceGetFn_t fn) +{ + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); + + std::string url = mCapability("GetMetadata"); + if (url.empty()) + { + LL_WARNS("ExperienceCache") << "No Metadata capability." << LL_ENDL; + return; + } + + LLSD fields; + fields.append("experience"); + LLSD data; + data["object-id"] = objectId; + data["item-id"] = itemId; + data["fields"] = fields; + + LLSD result = httpAdapter->postAndYield(httpRequest, url, data); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if ((!status) || (!result.has("experience"))) + { + LLSD failure; + if (!status) + { + failure["error"] = (LLSD::Integer)status.getType(); + failure["message"] = status.getMessage(); + } + else + { + failure["error"] = -1; + failure["message"] = "no experience"; + } + if (fn && !fn.empty()) + fn(failure); + return; + } + + LLUUID expId = result["experience"].asUUID(); + get(expId, fn); +} + +//========================================================================= void LLExperienceCacheImpl::mapKeys(const LLSD& legacyKeys) { LLSD::array_const_iterator exp = legacyKeys.beginArray(); |