wsproxy/server/wsproxy/jsondatamgr.cc
aozhiwei fc5ed7f577 1
2019-05-15 14:18:55 +08:00

63 lines
2.1 KiB
C++

#include "precompile.h"
#include "jsondatamgr.h"
#include "app.h"
void JsonDataMgr::Init()
{
std::string wsproxyserver_cluster_json_file;
#if MASTER_MODE
std::string masterserver_cluster_json_file;
#else
std::string targetserver_cluster_json_file;
#endif
if (f8::IsOnlineEnv()) {
wsproxyserver_cluster_json_file = a8::Format("../config/game%d.wsproxy.cluster.json", {GAME_ID});
#if MASTER_MODE
masterserver_cluster_json_file = a8::Format("../config/game%d.masterserver.cluster.json", {GAME_ID});
#else
targetserver_cluster_json_file = a8::Format("../config/game%d.gameserver.cluster.json", {GAME_ID});
#endif
} else {
wsproxyserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/wsproxy/game%d.wsproxy.cluster.json",
{GAME_ID, GAME_ID});
#if MASTER_MODE
masterserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/wsproxy/game%d.masterserver.cluster.json",
{GAME_ID, GAME_ID});
#else
targetserver_cluster_json_file = a8::Format("/var/data/conf_test/game%d/wsproxy/game%d.gameserver.cluster.json",
{GAME_ID, GAME_ID});
#endif
}
wsproxyserver_cluster_json_.ReadFromFile(wsproxyserver_cluster_json_file);
#if MASTER_MODE
masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file);
#else
targetserver_cluster_json_.ReadFromFile(targetserver_cluster_json_file);
#endif
}
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];
}
#if MASTER_MODE
std::shared_ptr<a8::XObject> JsonDataMgr::GetMasterServerClusterConf()
{
return std::make_shared<a8::XObject>(masterserver_cluster_json_);
}
#else
std::shared_ptr<a8::XObject> JsonDataMgr::GetTargetServerClusterConf()
{
return std::make_shared<a8::XObject>(targetserver_cluster_json_);
}
#endif