From 5587c3c85cb7d7c7d954371dfe09f7c112ae8b54 Mon Sep 17 00:00:00 2001 From: azw Date: Mon, 24 Apr 2023 11:12:32 +0000 Subject: [PATCH] 1 --- server/wsproxy/jsondatamgr.cc | 11 +++++++++++ server/wsproxy/jsondatamgr.h | 1 + 2 files changed, 12 insertions(+) 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_; }