This commit is contained in:
aozhiwei 2024-07-30 17:20:59 +08:00
parent be4a0d0bdf
commit b79e9ce548
5 changed files with 50 additions and 4 deletions

View File

@ -1,3 +1,4 @@
{
"api_url": "https://game2006api-test.kingsome.cn/webapp/index.php"
"api_url": "https://game2006api-test.kingsome.cn/webapp/index.php",
"api_secret_key": "BIgDh5J%uUktooKxT!IM7#m$NtB51%la"
}

View File

@ -1,3 +1,4 @@
{
"api_url": "https://game2006api-test.kingsome.cn/webapp/index.php"
"api_url": "https://game2006api-test.kingsome.cn/webapp/index.php",
"api_secret_key": "BIgDh5J%uUktooKxT!IM7#m$NtB51%la"
}

View File

@ -76,7 +76,7 @@ void BoxDrop::RequestAllocBoxNum()
int nowtime = f8::App::Instance()->GetNowTime();
auto url_params = a8::MutableXObject::CreateObject();
url_params->SetVal("c", "Battle");
url_params->SetVal("a", "requestBoxNum");
url_params->SetVal("a", "requestAllocBoxNum");
url_params->SetVal("timestamp", a8::XValue(nowtime));
HttpProxy::Instance()->HttpGet
(
@ -110,5 +110,46 @@ void BoxDrop::RequestAllocBoxNum()
void BoxDrop::RequestReturnBoxNum()
{
if (alloc_box_num_ <= 0) {
return;
}
if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) {
if (returned_) {
return;
}
returned_ = true;
std::string url;
JsonDataMgr::Instance()->GetApiUrl(url);
auto url_params = a8::MutableXObject::CreateObject();
url_params->SetVal("c", "Battle");
url_params->SetVal("a", "requestReturnBoxNum");
HttpProxy::Instance()->HttpGet
(
[]
(bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
{
if (ok) {
f8::UdpLog::Instance()->Info
("GetBattleData ok %s",
{
rsp_obj->ToJsonStr()
});
if (rsp_obj->GetType() != a8::XOT_OBJECT ||
!rsp_obj->HasKey("errcode")) {
//cb(1, "", nullptr);
return;
}
} else {
f8::UdpLog::Instance()->Warning
("GetCustomBattleData error %s",
{
""
});
//cb(1, "custom battle data error", nullptr);
}
},
url.c_str(),
*url_params
);
}
}

View File

@ -55,6 +55,7 @@ void JsonDataMgr::Init()
if (setting_json_.GetType() == a8::XOT_OBJECT &&
setting_json_.HasKey("api_url")) {
api_url_ = setting_json_.Get("api_url").GetString();
api_secret_key_ = setting_json_.Get("api_secret_key").GetString();
}
ip = GetConf()->At("ip")->AsXValue().GetString();

View File

@ -21,11 +21,13 @@ public:
std::string server_info;
void GetApiUrl(std::string& url);
std::string GetApiSecretKey() { return api_secret_key_; };
void GetHttpGetProxyUrl(std::string& url);
void GetHttpPostProxyUrl(std::string& url);
private:
std::string api_url_;
std::string api_secret_key_;
private:
std::string work_path_ = "../config";