$Date: 2007/12/17 08:39:08 $
*/
+#include "stg/const.h"
+#include "stg/ia_packets.h"
+
+#include <string>
+#include <list>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#include <jthread.hpp>
+#pragma GCC diagnostic pop
+
#ifndef WIN32
-#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <winsock2.h>
#endif
-#include <string>
-#include <list>
-
-#include "stg_const.h"
-#include "ia_packets.h"
-
-using namespace std;
-
#define MAX_MESSAGES (10)
//-----------------------------------------------------------------------------
struct STG_MESSAGE
{
-string msg;
-string recvTime;
-int type;
+ std::string msg;
+ std::string recvTime;
+ int type;
};
//-----------------------------------------------------------------------------
class WEB
{
-public:
- WEB();
- void Run();
- void SetDirName(const string & dn, int n);
- void SetRefreshPagePeriod(int p);
- void SetListenAddr(uint32_t ip);
- void AddMessage(const string & message, int type);
- void UpdateStat(const LOADSTAT & ls);
- void Start();
-private:
+ 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);
- void PrepareNet();
+ #ifdef WIN32
+ WSADATA m_wsaData;
+ #endif
- #ifdef WIN32
- WSADATA wsaData;
- #else
- pthread_t thread;
- #endif
+ std::jthread m_thread;
- int SendReply();
- int SendCSS();
- int Redirect(const char * url);
+ std::string m_dirName[DIR_NUM];
+ int m_res;
+ int m_listenSocket;
+ int m_outerSocket;
+ int m_refreshPeriod;
- string dirName[DIR_NUM];
- int res;
- int listenSocket;
- int outerSocket;
- struct sockaddr_in listenAddr;
- struct sockaddr_in outerAddr;
- int refreshPeriod;
+ uint32_t m_listenWebAddr;
+ LOADSTAT m_ls;
- uint32_t listenWebAddr;
- LOADSTAT ls;
-
- list<STG_MESSAGE> messages;
-
- #ifndef WIN32
- socklen_t outerAddrLen;
- #else
- int outerAddrLen;
- #endif
+ std::list<STG_MESSAGE> m_messages;
};
//-----------------------------------------------------------------------------
-