Coroutine voice account provision
parent
e2d6819374
commit
732fceca67
|
|
@ -124,66 +124,6 @@ static int scale_speaker_volume(float volume)
|
|||
|
||||
}
|
||||
|
||||
class LLVivoxVoiceAccountProvisionResponder :
|
||||
public LLHTTPClient::Responder
|
||||
{
|
||||
LOG_CLASS(LLVivoxVoiceAccountProvisionResponder);
|
||||
public:
|
||||
LLVivoxVoiceAccountProvisionResponder(int retries)
|
||||
{
|
||||
mRetries = retries;
|
||||
}
|
||||
|
||||
private:
|
||||
/* virtual */ void httpFailure()
|
||||
{
|
||||
LL_WARNS("Voice") << "ProvisionVoiceAccountRequest returned an error, "
|
||||
<< ( (mRetries > 0) ? "retrying" : "too many retries (giving up)" )
|
||||
<< " " << dumpResponse() << LL_ENDL;
|
||||
|
||||
if ( mRetries > 0 )
|
||||
{
|
||||
LLVivoxVoiceClient::getInstance()->requestVoiceAccountProvision(mRetries - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
LLVivoxVoiceClient::getInstance()->giveUp();
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void httpSuccess()
|
||||
{
|
||||
std::string voice_sip_uri_hostname;
|
||||
std::string voice_account_server_uri;
|
||||
|
||||
LL_DEBUGS("Voice") << "ProvisionVoiceAccountRequest response:" << dumpResponse() << LL_ENDL;
|
||||
|
||||
const LLSD& content = getContent();
|
||||
if (!content.isMap())
|
||||
{
|
||||
failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content);
|
||||
return;
|
||||
}
|
||||
if(content.has("voice_sip_uri_hostname"))
|
||||
voice_sip_uri_hostname = content["voice_sip_uri_hostname"].asString();
|
||||
|
||||
// this key is actually misnamed -- it will be an entire URI, not just a hostname.
|
||||
if(content.has("voice_account_server_name"))
|
||||
voice_account_server_uri = content["voice_account_server_name"].asString();
|
||||
|
||||
LLVivoxVoiceClient::getInstance()->login(
|
||||
content["username"].asString(),
|
||||
content["password"].asString(),
|
||||
voice_sip_uri_hostname,
|
||||
voice_account_server_uri);
|
||||
}
|
||||
|
||||
private:
|
||||
int mRetries;
|
||||
};
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class LLVivoxVoiceClientMuteListObserver : public LLMuteListObserver
|
||||
|
|
@ -505,16 +445,51 @@ void LLVivoxVoiceClient::requestVoiceAccountProvision(S32 retries)
|
|||
|
||||
if ( !url.empty() )
|
||||
{
|
||||
LLHTTPClient::post(
|
||||
url,
|
||||
LLSD(),
|
||||
new LLVivoxVoiceAccountProvisionResponder(retries));
|
||||
|
||||
LLCoros::instance().launch("LLVivoxVoiceClient::voiceAccountProvisionCoro",
|
||||
boost::bind(&LLVivoxVoiceClient::voiceAccountProvisionCoro, this, _1, url, retries));
|
||||
setState(stateConnectorStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLVivoxVoiceClient::voiceAccountProvisionCoro(LLCoros::self& self, std::string &url, S32 retries)
|
||||
{
|
||||
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
|
||||
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
|
||||
httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("voiceAccountProvision", httpPolicy));
|
||||
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
|
||||
LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
|
||||
|
||||
httpOpts->setRetries(retries);
|
||||
|
||||
LLSD result = httpAdapter->postAndYield(self, httpRequest, url, LLSD(), httpOpts);
|
||||
|
||||
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
|
||||
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
|
||||
|
||||
if (!status)
|
||||
{
|
||||
LL_WARNS("Voice") << "Unable to provision voice account." << LL_ENDL;
|
||||
giveUp();
|
||||
return;
|
||||
}
|
||||
|
||||
std::string voice_sip_uri_hostname;
|
||||
std::string voice_account_server_uri;
|
||||
|
||||
//LL_DEBUGS("Voice") << "ProvisionVoiceAccountRequest response:" << dumpResponse() << LL_ENDL;
|
||||
|
||||
if (result.has("voice_sip_uri_hostname"))
|
||||
voice_sip_uri_hostname = result["voice_sip_uri_hostname"].asString();
|
||||
|
||||
// this key is actually misnamed -- it will be an entire URI, not just a hostname.
|
||||
if (result.has("voice_account_server_name"))
|
||||
voice_account_server_uri = result["voice_account_server_name"].asString();
|
||||
|
||||
login(result["username"].asString(), result["password"].asString(),
|
||||
voice_sip_uri_hostname, voice_account_server_uri);
|
||||
}
|
||||
|
||||
void LLVivoxVoiceClient::login(
|
||||
const std::string& account_name,
|
||||
const std::string& password,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ class LLVivoxProtocolParser;
|
|||
#include "llvoiceclient.h"
|
||||
|
||||
class LLAvatarName;
|
||||
class LLVivoxVoiceAccountProvisionResponder;
|
||||
class LLVivoxVoiceClientMuteListObserver;
|
||||
|
||||
|
||||
|
|
@ -253,7 +252,6 @@ protected:
|
|||
//////////////////////
|
||||
// Vivox Specific definitions
|
||||
|
||||
friend class LLVivoxVoiceAccountProvisionResponder;
|
||||
friend class LLVivoxVoiceClientMuteListObserver;
|
||||
friend class LLVivoxVoiceClientFriendsObserver;
|
||||
|
||||
|
|
@ -637,6 +635,8 @@ protected:
|
|||
void accountGetTemplateFontsResponse(int statusCode, const std::string &statusString);
|
||||
|
||||
private:
|
||||
|
||||
void voiceAccountProvisionCoro(LLCoros::self& self, std::string &url, S32 retries);
|
||||
void parcelVoiceInfoRequestCoro(LLCoros::self& self, std::string &url);
|
||||
|
||||
LLVoiceVersionInfo mVoiceVersion;
|
||||
|
|
|
|||
Loading…
Reference in New Issue