code_app/sdk/webservice/WebServer.h

43 lines
902 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>
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 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<class WebUser*> m_vectorUser;
};