summaryrefslogtreecommitdiff
path: root/indra/newview/llvoicechannel.cpp
diff options
context:
space:
mode:
authorGlenn Glazer <coyot@lindenlab.com>2016-04-07 12:10:13 -0700
committerGlenn Glazer <coyot@lindenlab.com>2016-04-07 12:10:13 -0700
commit369cefd5b3f2f52ae0dd203fcd45a4618f74b0f3 (patch)
tree941d27a32099abaf71bae8a2865002e2b25a3512 /indra/newview/llvoicechannel.cpp
parent0494a502aafac73800352dc26c4eb3a27b02a8ce (diff)
parent18928ea6c6f2830a0d45ec412c915eceff1b76b0 (diff)
pull from viewer-release
Diffstat (limited to 'indra/newview/llvoicechannel.cpp')
-rwxr-xr-xindra/newview/llvoicechannel.cpp137
1 files changed, 64 insertions, 73 deletions
diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp
index 426ca332e4..3abb716593 100755
--- a/indra/newview/llvoicechannel.cpp
+++ b/indra/newview/llvoicechannel.cpp
@@ -28,7 +28,6 @@
#include "llagent.h"
#include "llfloaterreg.h"
-#include "llhttpclient.h"
#include "llimview.h"
#include "llnotifications.h"
#include "llnotificationsutil.h"
@@ -37,7 +36,7 @@
#include "llviewercontrol.h"
#include "llviewerregion.h"
#include "llvoicechannel.h"
-
+#include "llcorehttputil.h"
LLVoiceChannel::voice_channel_map_t LLVoiceChannel::sVoiceChannelMap;
LLVoiceChannel::voice_channel_map_uri_t LLVoiceChannel::sVoiceChannelURIMap;
@@ -52,71 +51,6 @@ BOOL LLVoiceChannel::sSuspended = FALSE;
//
const U32 DEFAULT_RETRIES_COUNT = 3;
-
-class LLVoiceCallCapResponder : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLVoiceCallCapResponder);
-public:
- LLVoiceCallCapResponder(const LLUUID& session_id) : mSessionID(session_id) {};
-
-protected:
- // called with bad status codes
- virtual void httpFailure();
- virtual void httpSuccess();
-
-private:
- LLUUID mSessionID;
-};
-
-
-void LLVoiceCallCapResponder::httpFailure()
-{
- LL_WARNS("Voice") << dumpResponse() << LL_ENDL;
- LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID);
- if ( channelp )
- {
- if ( HTTP_FORBIDDEN == getStatus() )
- {
- //403 == no ability
- LLNotificationsUtil::add(
- "VoiceNotAllowed",
- channelp->getNotifyArgs());
- }
- else
- {
- LLNotificationsUtil::add(
- "VoiceCallGenericError",
- channelp->getNotifyArgs());
- }
- channelp->deactivate();
- }
-}
-
-void LLVoiceCallCapResponder::httpSuccess()
-{
- LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID);
- if (channelp)
- {
- //*TODO: DEBUG SPAM
- const LLSD& content = getContent();
- if (!content.isMap())
- {
- failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content);
- return;
- }
- LLSD::map_const_iterator iter;
- for(iter = content.beginMap(); iter != content.endMap(); ++iter)
- {
- LL_DEBUGS("Voice") << "LLVoiceCallCapResponder::result got "
- << iter->first << LL_ENDL;
- }
-
- channelp->setChannelInfo(
- content["voice_credentials"]["channel_uri"].asString(),
- content["voice_credentials"]["channel_credentials"].asString());
- }
-}
-
//
// LLVoiceChannel
//
@@ -545,12 +479,9 @@ void LLVoiceChannelGroup::getChannelInfo()
if (region)
{
std::string url = region->getCapability("ChatSessionRequest");
- LLSD data;
- data["method"] = "call";
- data["session-id"] = mSessionID;
- LLHTTPClient::post(url,
- data,
- new LLVoiceCallCapResponder(mSessionID));
+
+ LLCoros::instance().launch("LLVoiceChannelGroup::voiceCallCapCoro",
+ boost::bind(&LLVoiceChannelGroup::voiceCallCapCoro, this, url));
}
}
@@ -673,6 +604,66 @@ void LLVoiceChannelGroup::setState(EState state)
}
}
+void LLVoiceChannelGroup::voiceCallCapCoro(std::string url)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("voiceCallCapCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+
+ LLSD postData;
+ postData["method"] = "call";
+ postData["session-id"] = mSessionID;
+
+ LL_INFOS("Voice", "voiceCallCapCoro") << "Generic POST for " << url << LL_ENDL;
+
+ LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(mSessionID);
+ if (!channelp)
+ {
+ LL_WARNS("Voice") << "Unable to retrieve channel with Id = " << mSessionID << LL_ENDL;
+ return;
+ }
+
+ if (!status)
+ {
+ if (status == LLCore::HttpStatus(HTTP_FORBIDDEN))
+ {
+ //403 == no ability
+ LLNotificationsUtil::add(
+ "VoiceNotAllowed",
+ channelp->getNotifyArgs());
+ }
+ else
+ {
+ LLNotificationsUtil::add(
+ "VoiceCallGenericError",
+ channelp->getNotifyArgs());
+ }
+ channelp->deactivate();
+ return;
+ }
+
+ result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS);
+
+ LLSD::map_const_iterator iter;
+ for (iter = result.beginMap(); iter != result.endMap(); ++iter)
+ {
+ LL_DEBUGS("Voice") << "LLVoiceCallCapResponder::result got "
+ << iter->first << LL_ENDL;
+ }
+
+ channelp->setChannelInfo(
+ result["voice_credentials"]["channel_uri"].asString(),
+ result["voice_credentials"]["channel_credentials"].asString());
+
+}
+
+
//
// LLVoiceChannelProximal
//