This commit is contained in:
aozhiwei 2024-08-21 22:23:05 +08:00
parent 332f84648b
commit ed541307fb
2 changed files with 34 additions and 6 deletions

View File

@ -72,9 +72,6 @@ behaviac::EBTStatus AndroidAgent::CoLogin()
auto url_params = a8::MutableXObject::CreateObject();
url_params->SetVal("c", "Login");
url_params->SetVal("a", "auth2");
//url_params->SetVal("gameid", 2006);
//url_params->SetVal("channel", 6513);
//url_params->SetVal("openid", owner_->GetIdx());
auto post_body = a8::MutableXObject::CreateObject();
post_body->SetVal("channel", 2);
post_body->SetVal("data", owner_->GetIdx());
@ -100,11 +97,27 @@ behaviac::EBTStatus AndroidAgent::CoLogin()
}
HttpProxy::Instance()->HttpGet
(
[context] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
[context, hum] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
{
#if 0
a8::XPrintf("data:%s\n", {rsp_obj->ToJsonStr()});
#endif
if (ok) {
long long hero_uniid = rsp_obj->Get("hero_unid", "");
hum->SetHeroUniId(hero_uniid);
if (hum->GetHeroUniId() <= 0) {
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", "selectFreeItemS");
url_params->SetVal("account_id", account_id);
url_params->SetVal("session_id", session_id);
url_params->SetVal("itemId", 30100);
HttpProxy::Instance()->HttpGet
(
[context, hum] (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
{
if (ok) {
++Perf::Instance()->enter_ok_times;
context->login_ok = true;
@ -113,6 +126,18 @@ behaviac::EBTStatus AndroidAgent::CoLogin()
++Perf::Instance()->enter_fail_times;
}
},
"https://game2006sapi-test.kingsome.cn/webapp/index.php",
url_params
);
} else {
++Perf::Instance()->enter_ok_times;
context->login_ok = true;
}
} else {
context->login_ok = false;
++Perf::Instance()->enter_fail_times;
}
},
"https://game2006api-test.kingsome.cn/webapp/index.php",
url_params
);

View File

@ -32,6 +32,8 @@ public:
const std::string& GetAccountId() { return account_id_; }
const std::string& GetSessionId() { return session_id_; }
void SetSessionId(const std::string& session_id) { session_id_ = session_id; }
void SetHeroUniId(long long hero_uniid) { hero_uniid_ = hero_uniid; }
long long GetHeroUniId() { return hero_uniid_; }
auto GetWebSocket() { return web_socket_; }
int GetIdx() { return idx_; }
void SetLoginSucess();
@ -76,6 +78,7 @@ private:
std::string session_id_;
std::string remote_ip_;
int remote_port_ = 0;
long long hero_uniid_ = 0;
bool is_login_success_ = false;
bool net_connected_ = false;