diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2011-08-30 09:52:25 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2011-08-30 09:52:25 -0400 |
commit | 5fb224bb8196e77259bef2a0ef60e82533c358a2 (patch) | |
tree | 1d0362a3b480cf422b279d14d5e9766c5b162961 | |
parent | f08d7fba9f2134a687169d8da478a44bdbe16955 (diff) |
CHOP-763: make sendReply() treat replyKey as optional.
It's not worth bothering to tweak reply LLSD or attempt to send it if the
incoming request has no replyKey, in effect not requesting a reply. This
supports LLEventAPI operations for which the caller might or might not care
about a reply, invoked using either send() (fire and forget) or request()
(send request, wait for response). This logic should be central, instead of
having to perform that test in every caller that cares.
The major alternative would have been to treat missing replyKey as an error
(whether LL_ERRS or exception). But since there's already a mechanism by which
an LLEventAPI operation method can stipulate its replyKey as required, at this
level we can let it be optional.
-rw-r--r-- | indra/llcommon/llevents.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp index ff03506e84..db1ea4792b 100644 --- a/indra/llcommon/llevents.cpp +++ b/indra/llcommon/llevents.cpp @@ -591,6 +591,17 @@ void LLReqID::stamp(LLSD& response) const bool sendReply(const LLSD& reply, const LLSD& request, const std::string& replyKey) { + // If the original request has no value for replyKey, it's pointless to + // construct or send a reply event: on which LLEventPump should we send + // it? Allow that to be optional: if the caller wants to require replyKey, + // it can so specify when registering the operation method. + if (! request.has(replyKey)) + { + return false; + } + + // Here the request definitely contains replyKey; reasonable to proceed. + // Copy 'reply' to modify it. LLSD newreply(reply); // Get the ["reqid"] element from request |