code_app/sdk/webservice/WebServer.h

45 lines
832 B
C
Raw Normal View History

2022-05-03 10:25:52 +00:00
#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:
2022-05-09 10:58:09 +00:00
WebServer(class MsgLoop *loop, HGUInt type);
2022-05-03 10:25:52 +00:00
~WebServer();
class MsgLoop* GetLoop();
HGUInt GetType();
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_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__ */