This commit is contained in:
azw 2023-04-24 11:30:57 +00:00
parent 415f509878
commit 0ec8f9133b
2 changed files with 12 additions and 12 deletions

View File

@ -18,16 +18,16 @@ void JsonDataMgr::Init()
});
}
std::string wsproxyserver_cluster_json_file;
std::string masterserver_cluster_json_file;
wsproxyserver_cluster_json_file = a8::Format
std::string wsproxy_cluster_json_file;
std::string master_cluster_json_file;
wsproxy_cluster_json_file = a8::Format
("%s/node%d/game%d.wsproxy.cluster.json",
{
work_path_,
App::Instance()->GetNodeId(),
GAME_ID
});
masterserver_cluster_json_file = a8::Format
master_cluster_json_file = a8::Format
("%s/node%d/game%d.masterserver.cluster.json",
{
work_path_,
@ -35,8 +35,8 @@ void JsonDataMgr::Init()
GAME_ID
});
wsproxyserver_cluster_json_.ReadFromFile(wsproxyserver_cluster_json_file);
masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file);
wsproxy_cluster_json_.ReadFromFile(wsproxy_cluster_json_file);
master_cluster_json_.ReadFromFile(master_cluster_json_file);
udp_host_ = GetConf()->At("listen_udp_host")->AsXValue().GetString();
udp_port_ = GetConf()->At("listen_udp_port")->AsXValue();
}
@ -47,8 +47,8 @@ void JsonDataMgr::UnInit()
std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
{
for (int i = 0; i < wsproxyserver_cluster_json_.Size(); ++i) {
std::shared_ptr<a8::XObject> conf = wsproxyserver_cluster_json_.At(i);
for (int i = 0; i < wsproxy_cluster_json_.Size(); ++i) {
std::shared_ptr<a8::XObject> conf = wsproxy_cluster_json_.At(i);
if (conf->At("instance_id")->AsXValue().GetInt() == App::Instance()->GetInstanceId()) {
return conf;
}
@ -58,8 +58,8 @@ std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
void JsonDataMgr::TraverseMaster(std::function<void (int, std::string, int)> cb)
{
for (int i = 0; i < masterserver_cluster_json_.Size(); ++i) {
auto master_svr_conf = masterserver_cluster_json_.At(i);
for (int i = 0; i < master_cluster_json_.Size(); ++i) {
auto master_svr_conf = master_cluster_json_.At(i);
int instance_id = master_svr_conf->At("instance_id")->AsXValue();
std::string remote_ip = master_svr_conf->At("ip")->AsXValue();
int remote_port = master_svr_conf->At("port")->AsXValue();

View File

@ -19,8 +19,8 @@ class JsonDataMgr : public a8::Singleton<JsonDataMgr>
private:
std::string work_path_ = "../config";
a8::XObject wsproxyserver_cluster_json_;
a8::XObject masterserver_cluster_json_;
a8::XObject wsproxy_cluster_json_;
a8::XObject master_cluster_json_;
std::string udp_host_;
int udp_port_ = 0;
};