47 lines
874 B
C++
47 lines
874 B
C++
#ifndef __WEBSERVER_H__
|
|
#define __WEBSERVER_H__
|
|
|
|
#include "../../base/HGDef.h"
|
|
#include "../../base/HGInc.h"
|
|
#include "../../base/HGThread.h"
|
|
#include "WebMsg.h"
|
|
#include <vector>
|
|
|
|
#define ServerType_Ws 1L
|
|
#define ServerType_Http 2L
|
|
#define ServerType_SockIo 3L
|
|
|
|
class WebServer
|
|
{
|
|
public:
|
|
WebServer(class MsgLoop *loop, HGUInt type, HGUInt id);
|
|
~WebServer();
|
|
|
|
class MsgLoop* GetLoop();
|
|
HGUInt GetType();
|
|
HGUInt GetId();
|
|
|
|
bool Open(HGUShort port);
|
|
bool Close();
|
|
void HandleMsg(const WebMsg* msg);
|
|
|
|
private:
|
|
int GetUserIndex(HGUInt id);
|
|
static void ThreadFunc(HGThread thread, HGPointer param);
|
|
|
|
private:
|
|
class MsgLoop* m_loop;
|
|
HGUInt m_type;
|
|
HGUInt m_id;
|
|
|
|
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;
|
|
};
|
|
|
|
#endif /* __WEBSERVER_H__ */ |