39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
#include "precompile.h"
|
|
|
|
#include "jsondatamgr.h"
|
|
#include "app.h"
|
|
|
|
void JsonDataMgr::Init()
|
|
{
|
|
std::string wsproxyserver_cluster_json_file;
|
|
std::string targetserver_cluster_json_file;
|
|
if (f8::IsOnlineEnv()) {
|
|
wsproxyserver_cluster_json_file = a8::Format("../config/game%d.wsproxy.cluster.json", {GAME_ID});
|
|
targetserver_cluster_json_file = a8::Format("../config/game%d.gameserver.cluster.json", {GAME_ID});
|
|
} else {
|
|
wsproxyserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/wsproxy/game%d.wsproxy.cluster.json",
|
|
{GAME_ID, GAME_ID});
|
|
targetserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/wsproxy/game%d.gameserver.cluster.json",
|
|
{GAME_ID, GAME_ID});
|
|
}
|
|
wsproxyserver_cluster_json_.ReadFromFile(wsproxyserver_cluster_json_file);
|
|
targetserver_cluster_json_.ReadFromFile(targetserver_cluster_json_file);
|
|
}
|
|
|
|
void JsonDataMgr::UnInit()
|
|
{
|
|
}
|
|
|
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
|
|
{
|
|
if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > wsproxyserver_cluster_json_.Size()) {
|
|
abort();
|
|
}
|
|
return wsproxyserver_cluster_json_[App::Instance()->instance_id - 1];
|
|
}
|
|
|
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetTargetServerClusterConf()
|
|
{
|
|
return std::make_shared<a8::XObject>(targetserver_cluster_json_);
|
|
}
|