#pragma once #include "base/HGDef.h" #include "base/HGInc.h" #include "base/HGThread.h" #include "base/HGMsgPump.h" #include "Msg.h" #include class WebServer { public: WebServer(HGMsgPump msgPump); virtual ~WebServer(); HGMsgPump GetMsgPump(); 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 std::string &ip, uint16_t port, SOCKET sockConn); #else void PostConnectMsg(const std::string &ip, uint16_t port, int sockConn); #endif int GetUserIndex(HGUInt id); static void HGAPI ThreadFunc(HGThread thread, HGPointer param); protected: HGMsgPump m_msgPump; HGUInt m_currUserId; #if defined(HG_CMP_MSC) SOCKET m_sockServer; #else int m_sockServer; #endif HGThread m_listenThread; std::vector m_vectorUser; };