2022-05-23 02:35:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "base/HGDef.h"
|
|
|
|
#include "base/HGInc.h"
|
|
|
|
#include "base/HGThread.h"
|
|
|
|
#include "base/HGMsgPump.h"
|
|
|
|
#include "Msg.h"
|
|
|
|
#include <vector>
|
|
|
|
|
2022-05-23 10:29:23 +00:00
|
|
|
class WebServer
|
2022-05-23 02:35:42 +00:00
|
|
|
{
|
2022-05-23 10:29:23 +00:00
|
|
|
public:
|
|
|
|
WebServer(HGMsgPump msgPump);
|
|
|
|
virtual ~WebServer();
|
2022-05-23 02:35:42 +00:00
|
|
|
|
2022-05-23 10:29:23 +00:00
|
|
|
HGMsgPump GetMsgPump();
|
|
|
|
bool Open(HGUShort port);
|
|
|
|
bool Close();
|
2022-05-23 02:35:42 +00:00
|
|
|
|
2022-05-23 10:29:23 +00:00
|
|
|
virtual void Connect(const ConnectParam* param) = 0;
|
|
|
|
void DisConnect(const DisConnectParam* param);
|
2022-05-23 02:35:42 +00:00
|
|
|
|
2022-05-23 10:29:23 +00:00
|
|
|
protected:
|
2022-05-23 02:35:42 +00:00
|
|
|
#if defined(HG_CMP_MSC)
|
2022-05-23 10:29:23 +00:00
|
|
|
void PostConnectMsg(const std::string &ip, uint16_t port, SOCKET sockConn);
|
2022-05-23 02:35:42 +00:00
|
|
|
#else
|
2022-05-23 10:29:23 +00:00
|
|
|
void PostConnectMsg(const std::string &ip, uint16_t port, int sockConn);
|
2022-05-23 02:35:42 +00:00
|
|
|
#endif
|
2022-05-23 10:29:23 +00:00
|
|
|
int GetUserIndex(HGUInt id);
|
|
|
|
static void ThreadFunc(HGThread thread, HGPointer param);
|
2022-05-23 02:35:42 +00:00
|
|
|
|
2022-05-23 10:29:23 +00:00
|
|
|
protected:
|
|
|
|
HGMsgPump m_msgPump;
|
2022-05-23 02:35:42 +00:00
|
|
|
|
2022-05-23 10:29:23 +00:00
|
|
|
HGUInt m_currUserId;
|
2022-05-23 02:35:42 +00:00
|
|
|
#if defined(HG_CMP_MSC)
|
2022-05-23 10:29:23 +00:00
|
|
|
SOCKET m_sockServer;
|
2022-05-23 02:35:42 +00:00
|
|
|
#else
|
2022-05-23 10:29:23 +00:00
|
|
|
int m_sockServer;
|
2022-05-23 02:35:42 +00:00
|
|
|
#endif
|
2022-05-23 10:29:23 +00:00
|
|
|
HGThread m_listenThread;
|
|
|
|
std::vector<class WebUser*> m_vectorUser;
|
|
|
|
};
|