diff --git a/server/wsproxy/jsondatamgr.cc b/server/wsproxy/jsondatamgr.cc index 97012e7..25b8567 100644 --- a/server/wsproxy/jsondatamgr.cc +++ b/server/wsproxy/jsondatamgr.cc @@ -5,17 +5,17 @@ void JsonDataMgr::Init() { - std::string masterserver_cluster_json_file; - std::string roomserver_cluster_json_file; - if (getenv("machine_type")) { - masterserver_cluster_json_file = "/var/data/conf_test/matchvs/masterserver/matchvs.masterserver.cluster.json"; - roomserver_cluster_json_file = "/var/data/conf_test/matchvs/masterserver/matchvs.roomserver.cluster.json"; + std::string wsproxyserver_cluster_json_file; + std::string targetserver_cluster_json_file; + if (getenv("is_dev_env")) { + wsproxyserver_cluster_json_file = "/var/data/conf_test/game1008/wsproxy/game1008.wsproxy.cluster.json"; + targetserver_cluster_json_file = "/var/data/conf_test/game1008/wsproxy/game1008.gameserver.cluster.json"; } else { - masterserver_cluster_json_file = "../config/matchvs.masterserver.cluster.json"; - roomserver_cluster_json_file = "../config/matchvs.roomserver.cluster.json"; + wsproxyserver_cluster_json_file = "../config/game1008.wsproxy.cluster.json"; + targetserver_cluster_json_file = "../config/game1008.gameserver.cluster.json"; } - masterserver_cluster_json_.ReadFromFile(masterserver_cluster_json_file); - roomserver_cluster_json_.ReadFromFile(roomserver_cluster_json_file); + wsproxyserver_cluster_json_.ReadFromFile(wsproxyserver_cluster_json_file); + targetserver_cluster_json_.ReadFromFile(targetserver_cluster_json_file); } void JsonDataMgr::UnInit() @@ -24,13 +24,13 @@ void JsonDataMgr::UnInit() std::shared_ptr 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(); } - return masterserver_cluster_json_[App::Instance()->instance_id - 1]; + return wsproxyserver_cluster_json_[App::Instance()->instance_id - 1]; } -std::shared_ptr JsonDataMgr::GetRoomServerClusterConf() +std::shared_ptr JsonDataMgr::GetTargetServerClusterConf() { - return std::make_shared(roomserver_cluster_json_); + return std::make_shared(targetserver_cluster_json_); } diff --git a/server/wsproxy/jsondatamgr.h b/server/wsproxy/jsondatamgr.h index bf232be..d99fe56 100644 --- a/server/wsproxy/jsondatamgr.h +++ b/server/wsproxy/jsondatamgr.h @@ -11,10 +11,10 @@ class JsonDataMgr : public a8::Singleton void UnInit(); std::shared_ptr GetConf(); - std::shared_ptr GetRoomServerClusterConf(); + std::shared_ptr GetTargetServerClusterConf(); private: - a8::XObject masterserver_cluster_json_; - a8::XObject roomserver_cluster_json_; + a8::XObject wsproxyserver_cluster_json_; + a8::XObject targetserver_cluster_json_; }; diff --git a/server/wsproxy/target_conn_mgr.cc b/server/wsproxy/target_conn_mgr.cc index f187278..0e19e51 100644 --- a/server/wsproxy/target_conn_mgr.cc +++ b/server/wsproxy/target_conn_mgr.cc @@ -1,9 +1,24 @@ #include "precompile.h" #include "target_conn_mgr.h" +#include "target_conn.h" +#include "jsondatamgr.h" 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()