This commit is contained in:
azw 2023-04-25 03:47:00 +00:00
parent 3a81c9ed37
commit ce2679496a
2 changed files with 27 additions and 7 deletions

View File

@ -20,6 +20,7 @@ void JsonDataMgr::Init()
std::string wsproxy_cluster_json_file;
std::string master_cluster_json_file;
std::string kcp_conf_json_file;
wsproxy_cluster_json_file = a8::Format
("%s/node%d/game%d.wsproxy.cluster.json",
{
@ -34,11 +35,29 @@ void JsonDataMgr::Init()
App::Instance()->GetNodeId(),
GAME_ID
});
kcp_conf_json_file = a8::Format
("%s/kcp_conf.json",
{
work_path_,
});
wsproxy_cluster_json_.ReadFromFile(wsproxy_cluster_json_file);
master_cluster_json_.ReadFromFile(master_cluster_json_file);
kcp_conf_json_.ReadFromFile(kcp_conf_json_file);
udp_host_ = GetConf()->At("listen_udp_host")->AsXValue().GetString();
udp_port_ = GetConf()->At("listen_udp_port")->AsXValue();
{
kcp_conf_.sndwnd = kcp_conf_json_.At("sndwnd")->AsXValue();
kcp_conf_.rcvwnd = kcp_conf_json_.At("rcvwnd")->AsXValue();
kcp_conf_.nodelay = kcp_conf_json_.At("nodelay")->AsXValue();
kcp_conf_.interval = kcp_conf_json_.At("interval")->AsXValue();
kcp_conf_.resend = kcp_conf_json_.At("resend")->AsXValue();
kcp_conf_.nc = kcp_conf_json_.At("nc")->AsXValue();
kcp_conf_.rx_minrto = kcp_conf_json_.At("rx_minrto")->AsXValue();
kcp_conf_.fastresend = kcp_conf_json_.At("fastresend")->AsXValue();
}
}
void JsonDataMgr::UnInit()

View File

@ -4,16 +4,16 @@
struct KcpConf
{
int sndwnd = 128;
int rcvwnd = 128;
int sndwnd = 0;
int rcvwnd = 0;
int nodelay = 2;
int interval = 10;
int resend = 2;
int nc = 1;
int nodelay = 0;
int interval = 0;
int resend = 0;
int nc = 0;
int rx_minrto = 0;
int fastresend = 1;
int fastresend = 0;
};
class JsonDataMgr : public a8::Singleton<JsonDataMgr>
@ -36,6 +36,7 @@ class JsonDataMgr : public a8::Singleton<JsonDataMgr>
std::string work_path_ = "../config";
a8::XObject wsproxy_cluster_json_;
a8::XObject master_cluster_json_;
a8::XObject kcp_conf_json_;
std::string udp_host_;
int udp_port_ = 0;
KcpConf kcp_conf_ = {};