mirror of
https://github.com//cppla/ServerStatus
synced 2026-03-26 16:29:46 +08:00
MMP, Cancel fork, because i do not know how to merge to the original foreign author
This commit is contained in:
93
server/src/main.h
Normal file
93
server/src/main.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "server.h"
|
||||
|
||||
class CConfig
|
||||
{
|
||||
public:
|
||||
bool m_Verbose;
|
||||
char m_aConfigFile[1024];
|
||||
char m_aWebDir[1024];
|
||||
char m_aTemplateFile[1024];
|
||||
char m_aJSONFile[1024];
|
||||
char m_aBindAddr[256];
|
||||
int m_Port;
|
||||
|
||||
CConfig();
|
||||
};
|
||||
|
||||
class CMain
|
||||
{
|
||||
CConfig m_Config;
|
||||
CServer m_Server;
|
||||
|
||||
struct CClient
|
||||
{
|
||||
bool m_Active;
|
||||
bool m_Disabled;
|
||||
bool m_Connected;
|
||||
int m_ClientNetID;
|
||||
int m_ClientNetType;
|
||||
char m_aUsername[128];
|
||||
char m_aName[128];
|
||||
char m_aType[128];
|
||||
char m_aHost[128];
|
||||
char m_aLocation[128];
|
||||
char m_aPassword[128];
|
||||
|
||||
int64 m_TimeConnected;
|
||||
int64 m_LastUpdate;
|
||||
|
||||
struct CStats
|
||||
{
|
||||
bool m_Online4;
|
||||
bool m_Online6;
|
||||
bool m_IpStatus; //mh361 or mh370, mourn mh370, 2014-03-0 01:20 lost from all over the world.
|
||||
int64_t m_Uptime;
|
||||
double m_Load_1; //1 minutes load average
|
||||
double m_Load_5; //5 minutes load average
|
||||
double m_Load_15; //15 minutes load average
|
||||
int64_t m_NetworkRx;
|
||||
int64_t m_NetworkTx;
|
||||
int64_t m_NetworkIN;
|
||||
int64_t m_NetworkOUT;
|
||||
int64_t m_MemTotal;
|
||||
int64_t m_MemUsed;
|
||||
int64_t m_SwapTotal;
|
||||
int64_t m_SwapUsed;
|
||||
int64_t m_HDDTotal;
|
||||
int64_t m_HDDUsed;
|
||||
double m_CPU;
|
||||
char m_aCustom[512];
|
||||
// Options
|
||||
bool m_Pong;
|
||||
} m_Stats;
|
||||
} m_aClients[NET_MAX_CLIENTS];
|
||||
|
||||
struct CJSONUpdateThreadData
|
||||
{
|
||||
CClient *pClients;
|
||||
CConfig *pConfig;
|
||||
volatile short m_ReloadRequired;
|
||||
} m_JSONUpdateThreadData;
|
||||
|
||||
static void JSONUpdateThread(void *pUser);
|
||||
public:
|
||||
CMain(CConfig Config);
|
||||
|
||||
void OnNewClient(int ClienNettID, int ClientID);
|
||||
void OnDelClient(int ClientNetID);
|
||||
int HandleMessage(int ClientNetID, char *pMessage);
|
||||
int ReadConfig();
|
||||
int Run();
|
||||
|
||||
CClient *Client(int ClientID) { return &m_aClients[ClientID]; }
|
||||
CClient *ClientNet(int ClientNetID);
|
||||
const CConfig *Config() const { return &m_Config; }
|
||||
int ClientNetToClient(int ClientNetID);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user