完成配置文件读取
This commit is contained in:
parent
3579312655
commit
f230e141db
@ -5,17 +5,17 @@
|
|||||||
|
|
||||||
void JsonDataMgr::Init()
|
void JsonDataMgr::Init()
|
||||||
{
|
{
|
||||||
std::string masterserver_cluster_json_file;
|
std::string wsproxyserver_cluster_json_file;
|
||||||
std::string roomserver_cluster_json_file;
|
std::string targetserver_cluster_json_file;
|
||||||
if (getenv("machine_type")) {
|
if (getenv("is_dev_env")) {
|
||||||
masterserver_cluster_json_file = "/var/data/conf_test/matchvs/masterserver/matchvs.masterserver.cluster.json";
|
wsproxyserver_cluster_json_file = "/var/data/conf_test/game1008/wsproxy/game1008.wsproxy.cluster.json";
|
||||||
roomserver_cluster_json_file = "/var/data/conf_test/matchvs/masterserver/matchvs.roomserver.cluster.json";
|
targetserver_cluster_json_file = "/var/data/conf_test/game1008/wsproxy/game1008.gameserver.cluster.json";
|
||||||
} else {
|
} else {
|
||||||
masterserver_cluster_json_file = "../config/matchvs.masterserver.cluster.json";
|
wsproxyserver_cluster_json_file = "../config/game1008.wsproxy.cluster.json";
|
||||||
roomserver_cluster_json_file = "../config/matchvs.roomserver.cluster.json";
|
targetserver_cluster_json_file = "../config/game1008.gameserver.cluster.json";
|
||||||
}
|
}
|
||||||
masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file);
|
wsproxyserver_cluster_json_.ReadFromFile(wsproxyserver_cluster_json_file);
|
||||||
roomserver_cluster_json_.ReadFromFile(roomserver_cluster_json_file);
|
targetserver_cluster_json_.ReadFromFile(targetserver_cluster_json_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonDataMgr::UnInit()
|
void JsonDataMgr::UnInit()
|
||||||
@ -24,13 +24,13 @@ void JsonDataMgr::UnInit()
|
|||||||
|
|
||||||
std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetConf()
|
||||||
{
|
{
|
||||||
if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > masterserver_cluster_json_.Size()) {
|
if (App::Instance()->instance_id < 1 || App::Instance()->instance_id > wsproxyserver_cluster_json_.Size()) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
return masterserver_cluster_json_[App::Instance()->instance_id - 1];
|
return wsproxyserver_cluster_json_[App::Instance()->instance_id - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<a8::XObject> JsonDataMgr::GetRoomServerClusterConf()
|
std::shared_ptr<a8::XObject> JsonDataMgr::GetTargetServerClusterConf()
|
||||||
{
|
{
|
||||||
return std::make_shared<a8::XObject>(roomserver_cluster_json_);
|
return std::make_shared<a8::XObject>(targetserver_cluster_json_);
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@ class JsonDataMgr : public a8::Singleton<JsonDataMgr>
|
|||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
std::shared_ptr<a8::XObject> GetConf();
|
std::shared_ptr<a8::XObject> GetConf();
|
||||||
std::shared_ptr<a8::XObject> GetRoomServerClusterConf();
|
std::shared_ptr<a8::XObject> GetTargetServerClusterConf();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
a8::XObject masterserver_cluster_json_;
|
a8::XObject wsproxyserver_cluster_json_;
|
||||||
a8::XObject roomserver_cluster_json_;
|
a8::XObject targetserver_cluster_json_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,24 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include "target_conn_mgr.h"
|
#include "target_conn_mgr.h"
|
||||||
|
#include "target_conn.h"
|
||||||
|
#include "jsondatamgr.h"
|
||||||
|
|
||||||
void TargetConnMgr::Init()
|
void TargetConnMgr::Init()
|
||||||
{
|
{
|
||||||
|
auto target_server_cluster_conf = JsonDataMgr::Instance()->GetTargetServerClusterConf();
|
||||||
|
for (int i = 0; i < target_server_cluster_conf->Size(); ++i) {
|
||||||
|
auto target_server_conf = target_server_cluster_conf->At(i);
|
||||||
|
int instance_id = target_server_conf->At("instance_id")->AsXValue();
|
||||||
|
std::string remote_ip = target_server_conf->At("ip")->AsXValue();
|
||||||
|
int remote_port = target_server_conf->At("port")->AsXValue();
|
||||||
|
{
|
||||||
|
TargetConn* conn = new TargetConn();
|
||||||
|
conn->Init(instance_id, remote_ip, remote_port);
|
||||||
|
target_conn_hash_[conn->instance_id] = conn;
|
||||||
|
conn->Open();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetConnMgr::UnInit()
|
void TargetConnMgr::UnInit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user