X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/0907aa4037b12b6b88ee24495d4577a064d4f8db..73bee151e048054bde9a39c5ad2efec25af9c77b:/projects/sgauth/web.h?ds=sidebyside diff --git a/projects/sgauth/web.h b/projects/sgauth/web.h index a933230a..a5ec8e6a 100644 --- a/projects/sgauth/web.h +++ b/projects/sgauth/web.h @@ -23,8 +23,17 @@ $Date: 2007/12/17 08:39:08 $ */ +#include "stg/const.h" +#include "stg/ia_packets.h" + +#include +#include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#include +#pragma GCC diagnostic pop + #ifndef WIN32 -#include #include #include #include @@ -36,53 +45,47 @@ #include #endif -#include -#include - -#include "stg/const.h" -#include "stg/ia_packets.h" - #define MAX_MESSAGES (10) //----------------------------------------------------------------------------- struct STG_MESSAGE { -std::string msg; -std::string recvTime; -int type; + std::string msg; + std::string recvTime; + int type; }; //----------------------------------------------------------------------------- class WEB { -public: - WEB(); - void Run(); - void SetDirName(const std::string & dn, int n); - void SetRefreshPagePeriod(int p); - void SetListenAddr(uint32_t ip); - void AddMessage(const std::string & message, int type); - void UpdateStat(const LOADSTAT & ls); - void Start(); -private: - void PrepareNet(); - int SendReply(); - int SendCSS(); - int Redirect(const char * url); + public: + WEB(); + void SetDirName(const std::string & dn, int n); + void SetRefreshPagePeriod(int p); + void SetListenAddr(uint32_t ip); + void AddMessage(const std::string & message, int type); + void UpdateStat(const LOADSTAT & ls); + void Start(); + private: + void Run(std::stop_token token) noexcept; + void PrepareNet(); + int SendReply(); + int SendCSS(); + int Redirect(const char * url); + + #ifdef WIN32 + WSADATA m_wsaData; + #endif - #ifdef WIN32 - WSADATA wsaData; - #else - pthread_t thread; - #endif + std::jthread m_thread; - std::string dirName[DIR_NUM]; - int res; - int listenSocket; - int outerSocket; - int refreshPeriod; + std::string m_dirName[DIR_NUM]; + int m_res; + int m_listenSocket; + int m_outerSocket; + int m_refreshPeriod; - uint32_t listenWebAddr; - LOADSTAT ls; + uint32_t m_listenWebAddr; + LOADSTAT m_ls; - std::list messages; + std::list m_messages; }; //-----------------------------------------------------------------------------