1
This commit is contained in:
parent
a1204c1dca
commit
979806c56c
@ -778,7 +778,7 @@ void RoomMgr::SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_m
|
||||
if (join_msgs.empty()) {
|
||||
abort();
|
||||
}
|
||||
std::vector<BattleDataContext> result;
|
||||
std::shared_ptr<std::vector<BattleDataContext>> result = std::make_shared<std::vector<BattleDataContext>>();
|
||||
bool is_old_version = false;
|
||||
for (auto& msg : join_msgs) {
|
||||
if (msg->proto_version() < 2022032201) {
|
||||
@ -787,37 +787,54 @@ void RoomMgr::SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_m
|
||||
}
|
||||
BattleDataContext context;
|
||||
context.join_msg = msg;
|
||||
result.push_back(context);
|
||||
result->push_back(context);
|
||||
}
|
||||
if (is_old_version) {
|
||||
cb(result);
|
||||
cb(*result);
|
||||
}
|
||||
std::string url;
|
||||
JsonDataMgr::Instance()->GetApiUrl(url);
|
||||
if (!f8::IsOnlineEnv()) {
|
||||
{
|
||||
std::string url;
|
||||
JsonDataMgr::Instance()->GetApiUrl(url);
|
||||
if (!f8::IsOnlineEnv()) {
|
||||
#ifdef DEBUG
|
||||
if (!is_old_version) {
|
||||
url = "https://game2006api-test.kingsome.cn/new/webapp/index.php";
|
||||
}
|
||||
if (!is_old_version) {
|
||||
url = "https://game2006api-test.kingsome.cn/new/webapp/index.php";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (url.find('?') != std::string::npos) {
|
||||
url += "c=Battle&a=getBattleData";
|
||||
} else {
|
||||
url += "?c=Battle&a=getBattleData";
|
||||
}
|
||||
a8::MutableXObject* url_params = a8::MutableXObject::NewObject();
|
||||
HttpProxy::Instance()->HttpGet
|
||||
(
|
||||
a8::XParams()
|
||||
.SetSender(new std::shared_ptr<std::vector<BattleDataContext>>(result))
|
||||
.SetParam1(new std::function<
|
||||
void(std::vector<BattleDataContext>&)>(cb)),
|
||||
[] (a8::XParams& param, a8::XObject& data)
|
||||
{
|
||||
auto result = (std::shared_ptr<std::vector<BattleDataContext>>*)param.sender.GetUserData();
|
||||
auto cb = (std::function<
|
||||
void(std::vector<BattleDataContext>&)>*)param.param1.GetUserData();
|
||||
(*cb)(*result->get());
|
||||
delete cb;
|
||||
delete result;
|
||||
},
|
||||
[] (a8::XParams& param, const std::string& response)
|
||||
{
|
||||
auto result = (std::shared_ptr<std::vector<BattleDataContext>>*)param.sender.GetUserData();
|
||||
auto cb = (std::function<
|
||||
void(std::vector<BattleDataContext>&)>*)param.param1.GetUserData();
|
||||
(*cb)(*result->get());
|
||||
delete cb;
|
||||
delete result;
|
||||
},
|
||||
url.c_str(),
|
||||
*url_params
|
||||
);
|
||||
delete url_params;
|
||||
}
|
||||
if (url.find('?') != std::string::npos) {
|
||||
url += "c=Battle&a=getBattleData";
|
||||
} else {
|
||||
url += "?c=Battle&a=getBattleData";
|
||||
}
|
||||
a8::MutableXObject* url_params = a8::MutableXObject::NewObject();
|
||||
HttpProxy::Instance()->HttpGet
|
||||
(
|
||||
a8::XParams(),
|
||||
[] (a8::XParams& param, a8::XObject& data)
|
||||
{
|
||||
},
|
||||
[] (a8::XParams& param, const std::string& response)
|
||||
{
|
||||
},
|
||||
url.c_str(),
|
||||
*url_params
|
||||
);
|
||||
delete url_params;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user