diff --git a/server/wsproxy/jsondatamgr.cc b/server/wsproxy/jsondatamgr.cc index d492587..6fafa4f 100644 --- a/server/wsproxy/jsondatamgr.cc +++ b/server/wsproxy/jsondatamgr.cc @@ -82,3 +82,14 @@ std::shared_ptr JsonDataMgr::GetMasterServerClusterConf() { return std::make_shared(masterserver_cluster_json_); } + +void JsonDataMgr::TraverseMaster(std::function cb) +{ + for (int i = 0; i < masterserver_cluster_json_.Size(); ++i) { + auto master_svr_conf = masterserver_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(); + cb(instance_id, remote_ip, remote_port); + } +} diff --git a/server/wsproxy/jsondatamgr.h b/server/wsproxy/jsondatamgr.h index ce0797e..f3ee7bd 100644 --- a/server/wsproxy/jsondatamgr.h +++ b/server/wsproxy/jsondatamgr.h @@ -14,6 +14,7 @@ class JsonDataMgr : public a8::Singleton std::shared_ptr GetConf(); std::shared_ptr GetMasterServerClusterConf(); + void TraverseMaster(std::function cb); std::string GetUdpHost() { return udp_host_; } int GetUdpPort() { return udp_port_; }