51 lines
1011 B
C
51 lines
1011 B
C
|
#pragma once
|
||
|
|
||
|
#include "base/HGDef.h"
|
||
|
#include "base/HGInc.h"
|
||
|
#include "base/HGThread.h"
|
||
|
#include "base/HGMsgPump.h"
|
||
|
#include "Msg.h"
|
||
|
#include <vector>
|
||
|
|
||
|
namespace ver_1
|
||
|
{
|
||
|
class Manager;
|
||
|
|
||
|
class WebServer
|
||
|
{
|
||
|
public:
|
||
|
WebServer(HGMsgPump msgPump, Manager* manager);
|
||
|
virtual ~WebServer();
|
||
|
|
||
|
HGMsgPump GetMsgPump();
|
||
|
Manager* GetManager();
|
||
|
|
||
|
bool Open(HGUShort port);
|
||
|
bool Close();
|
||
|
|
||
|
virtual void Connect(const ConnectParam* param) = 0;
|
||
|
void DisConnect(const DisConnectParam* param);
|
||
|
|
||
|
protected:
|
||
|
#if defined(HG_CMP_MSC)
|
||
|
void PostConnectMsg(const char* ip, uint16_t port, SOCKET sockConn);
|
||
|
#else
|
||
|
void PostConnectMsg(const char* ip, uint16_t port, int sockConn);
|
||
|
#endif
|
||
|
int GetUserIndex(HGUInt id);
|
||
|
static void ThreadFunc(HGThread thread, HGPointer param);
|
||
|
|
||
|
protected:
|
||
|
HGMsgPump m_msgPump;
|
||
|
Manager* m_manager;
|
||
|
|
||
|
HGUInt m_currUserId;
|
||
|
#if defined(HG_CMP_MSC)
|
||
|
SOCKET m_sockServer;
|
||
|
#else
|
||
|
int m_sockServer;
|
||
|
#endif
|
||
|
HGThread m_listenThread;
|
||
|
std::vector<class WebUser*> m_vectorUser;
|
||
|
};
|
||
|
}
|