Distribution_Service/Server/Configuration/Config.h

93 lines
3.3 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"
#include "CCJSONObject.h"
#include "CCString.h"
2025-11-11 18:09:51 +08:00
2025-12-05 16:46:23 +08:00
struct ConfigTerm{
char macChkStr[20]; //终端Mac
char termIDnVerStr[20]; //发送的是软件版本接收的是终端ID
char macStr[20]; //终端Mac地址
char servIPAddrStr[20]; //服务器IP地址
char termIPAddrStr[20]; //终端IP
char termIPGwStr[20]; //终端IP网关
char termIPNmStr[20]; //子网掩码
char termCmdPortStr[6]; //终端指令端口号
char servCmdPortStr[6]; //服务器指令端口号
char termStmPortStr[6]; //终端码流端口号
char workModeStr[2]; //工作模式
char btNameStr[32]; //蓝牙音频名称
char dhcpFlagStr[2]; //DHCP开关标识
char btPwdStr[5]; //蓝牙音频密码
char termTypeStr[6]; //终端类型
char sipUsrNameStr[30]; //SIP用户名称
char sipUsrPwdStr[30]; //SIP用户密码
char sipProxyRealmStr[30]; //SIP服务器IP地址/域名
char cmdFlagByteStr[3]; //指令标识
char onlineFlagStr[2]; //在线状态标志
};
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
2026-03-24 18:14:23 +08:00
,Name,WorkingMode,TermNumber,DHCPFlag,TermIPGw,TermIPNm);
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;
2026-03-24 18:14:23 +08:00
CTL::String IP = "";
2025-12-03 18:08:23 +08:00
CTL::String ServerIP = "192.168.2.208"; // 目标主服务器IP
int ServerPort = 10060; // 目标主服务器端口
int OrderPort = 10050; // 10060
2025-12-05 16:46:23 +08:00
int ConfigPort = 22060; // 22060
2025-11-11 18:09:51 +08:00
int StreamPort = 10062;
2025-12-05 16:46:23 +08:00
bool isConnect = false;
2025-11-11 18:09:51 +08:00
int HttpPort = 9090;
2025-12-10 18:23:34 +08:00
int WorkingMode = 0; // 工作模式
int TermNumber = 0; // 机器编号
int DHCPFlag = 0; // DHCP开关标识
2025-11-11 18:09:51 +08:00
bool Flag = false;
2025-12-05 16:46:23 +08:00
CTL::String MacAddr;
CTL::String TermIPGw;
CTL::String TermIPNm;
CTL::String Ver = "DS:V0.11(251205A)";
2026-03-24 14:43:26 +08:00
static std::shared_mutex m_mutex_udp;
2025-12-03 18:08:23 +08:00
CTL::DatagramSocket* m_socket_udp = nullptr;
2026-03-24 14:43:26 +08:00
static std::shared_mutex m_mutex_udp_tool;
2025-12-05 16:46:23 +08:00
CTL::DatagramSocket* m_socket_udp_tool = nullptr;
2025-12-03 18:08:23 +08:00
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-12-05 16:46:23 +08:00
static ConfigTerm *getThisInfo();
static void groupBroadcast(const CTL::ByteArray& data,int port);
static void SetNetWorkInfo(const CTL::String& IP,const CTL::String& GW,const CTL::String& Mask);
static void CloseService();
static CTL::String GetNetMaskCIDR(const CTL::String& Mask);/*获取CIDR格式子网掩码*/
2025-12-10 18:23:34 +08:00
static char getTermWorkInfo(char index);
2025-11-11 18:09:51 +08:00
};
#endif