1
This commit is contained in:
parent
1eec34422e
commit
8c178966f5
@ -49,8 +49,15 @@ behaviac::EBTStatus AndroidAgent::CoIdle(int min_val, int max_val)
|
||||
|
||||
behaviac::EBTStatus AndroidAgent::CoLogin()
|
||||
{
|
||||
PRE_ENTER_COROUTINE();
|
||||
auto context = MAKE_BTCONTEXT
|
||||
(
|
||||
std::string account_id;
|
||||
std::optional<bool> login_ok;
|
||||
);
|
||||
context->account_id = owner_->GetAccountId();
|
||||
auto co = std::make_shared<BtCoroutine>(context, co_id, "CoLogin");
|
||||
{
|
||||
bool ret = false;
|
||||
auto url_params = a8::MutableXObject::CreateObject();
|
||||
url_params->SetVal("c", "Login");
|
||||
url_params->SetVal("a", "auth");
|
||||
@ -59,16 +66,46 @@ behaviac::EBTStatus AndroidAgent::CoLogin()
|
||||
url_params->SetVal("openid", owner_->GetIdx());
|
||||
HttpProxy::Instance()->HttpGet
|
||||
(
|
||||
[] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
|
||||
[context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
|
||||
{
|
||||
if (ok) {
|
||||
std::string account_id = rsp_obj->At("account_id")->AsXValue().GetString();
|
||||
std::string session_id = rsp_obj->At("session_id")->AsXValue().GetString();
|
||||
auto url_params = a8::MutableXObject::CreateObject();
|
||||
url_params->SetVal("c", "User");
|
||||
url_params->SetVal("a", "login");
|
||||
url_params->SetVal("account_id", account_id);
|
||||
url_params->SetVal("session_id", session_id);
|
||||
HttpProxy::Instance()->HttpGet
|
||||
(
|
||||
[context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
|
||||
{
|
||||
if (ok) {
|
||||
|
||||
} else {
|
||||
context->login_ok = false;
|
||||
}
|
||||
},
|
||||
"https://game2006api-test.kingsome.cn/webapp/index.php",
|
||||
*url_params
|
||||
);
|
||||
} else {
|
||||
context->login_ok = false;
|
||||
}
|
||||
},
|
||||
"https://login-test.kingsome.cn/webapp/index.php",
|
||||
*url_params
|
||||
);
|
||||
}
|
||||
return behaviac::BT_SUCCESS;
|
||||
co->runing_cb =
|
||||
[this, context] (BtCoroutine* co)
|
||||
{
|
||||
if (context->login_ok == std::nullopt) {
|
||||
return behaviac::BT_RUNNING;
|
||||
}
|
||||
return behaviac::BT_SUCCESS;
|
||||
};
|
||||
return StartCoroutine(co);
|
||||
}
|
||||
|
||||
behaviac::EBTStatus AndroidAgent::CoConnectBattleServer()
|
||||
|
@ -31,9 +31,10 @@
|
||||
class Context : public BtContext \
|
||||
{public: \
|
||||
__VA_ARGS__; \
|
||||
long long frameno = 0; \
|
||||
long long create_tick = 0; \
|
||||
}; \
|
||||
auto context = std::make_shared<Context>(); \
|
||||
context->create_tick = a8::XGetTickCount(); \
|
||||
return context; \
|
||||
}(this)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user