From ed541307fb7faac4ece03ff852462afad9881fe9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 22:23:05 +0800 Subject: [PATCH] 1 --- server/robotserver/android_agent.cc | 37 ++++++++++++++++++++++++----- server/robotserver/player.h | 3 +++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/server/robotserver/android_agent.cc b/server/robotserver/android_agent.cc index 305c3ccc..52c1c083 100644 --- a/server/robotserver/android_agent.cc +++ b/server/robotserver/android_agent.cc @@ -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,14 +97,42 @@ 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) { - ++Perf::Instance()->enter_ok_times; - context->login_ok = true; + 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; + } else { + context->login_ok = false; + ++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; diff --git a/server/robotserver/player.h b/server/robotserver/player.h index eab6897f..2491348c 100644 --- a/server/robotserver/player.h +++ b/server/robotserver/player.h @@ -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;