Distribution_Service/Server/Configuration/Config.h

53 lines
1.5 KiB
C
Raw Normal View History

2025-11-11 18:09:51 +08:00
#ifndef DISTRIBUTION_SERVICE_CONFIG_H
#define DISTRIBUTION_SERVICE_CONFIG_H
2025-12-03 18:08:23 +08:00
#include "CCDatagramSocket.h"
#include "CCFile.h"
2025-11-11 18:09:51 +08:00
#include "CCSystem.h"
2025-12-03 18:08:23 +08:00
#include "CCJSONObject.h"
#include "CCString.h"
2025-11-11 18:09:51 +08:00
class Config {
2025-12-03 18:08:23 +08:00
JSON_TYPE_INTRUSIVE(Config,IP,OrderPort,StreamPort,HttpPort,Flag,ServerID,ServerIP,ServerPort,ID
,Name);
2025-11-11 18:09:51 +08:00
public:
2025-12-03 18:08:23 +08:00
int ServerID = 2;
int ID = 1;
CTL::String Name = "Distribution 1";
int ONLINEVol = 1;
2025-11-11 18:09:51 +08:00
CTL::String IP = "0.0.0.0";
2025-12-03 18:08:23 +08:00
CTL::String ServerIP = "192.168.2.208"; // 目标主服务器IP
int ServerPort = 10060; // 目标主服务器端口
int OrderPort = 10050; // 10060
2025-11-11 18:09:51 +08:00
int StreamPort = 10062;
int HttpPort = 9090;
bool Flag = false;
2025-12-03 18:08:23 +08:00
CTL::DatagramSocket* m_socket_udp = nullptr;
CTL::IPVX IP_x = CTL::IPV4;
2025-11-11 18:09:51 +08:00
private:
public:
2025-12-03 18:08:23 +08:00
static void Save();
static void Init();
2025-11-11 18:09:51 +08:00
static Config* getConfig();
static bool IsRunning();
2025-12-03 18:08:23 +08:00
static CTL::String GetFileDir() {
return CCFile::NormalizePath("./");
}
static CTL::String GetSettingDir() {
const auto root = GetFileDir();
const auto path = CCFile::NormalizePath(root + "/Setting");
const CCFile file(path);
if(!file.isExists()){
CCFile::Create(path,true);
}
return path;
}
static CTL::String GetSettingDB() {
const auto root = GetSettingDir();
return CCFile::NormalizePath(root + "/Setting.json");
}
static CTL::String GetIP();
2025-11-11 18:09:51 +08:00
};
#endif