50 lines
989 B
C++
50 lines
989 B
C++
|
#include "base/HGDef.h"
|
|||
|
#include "base/HGInc.h"
|
|||
|
#include "base/HGThread.h"
|
|||
|
#include "base/HGMsgPump.h"
|
|||
|
#include "WebServer.h"
|
|||
|
#include "MsgPumpCallback.h"
|
|||
|
|
|||
|
static void ThreadFunc(HGThread thread, HGPointer param)
|
|||
|
{
|
|||
|
(void)thread;
|
|||
|
HGMsgPump msgPump = (HGMsgPump)param;
|
|||
|
|
|||
|
WebServer wsServer(msgPump);
|
|||
|
|
|||
|
HGInt port = 9458;
|
|||
|
if (wsServer.Open(port))
|
|||
|
{
|
|||
|
HGBase_RunMsgPump(msgPump, HGMsgPumpCallback, NULL);
|
|||
|
wsServer.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#if defined(HG_CMP_MSC)
|
|||
|
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE iPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
|
|||
|
#else
|
|||
|
int main()
|
|||
|
#endif
|
|||
|
{
|
|||
|
#if defined(HG_CMP_MSC)
|
|||
|
WSADATA ws = { 0 };
|
|||
|
int ret = WSAStartup(MAKEWORD(2, 2), &ws);
|
|||
|
assert(0 == ret);
|
|||
|
#endif
|
|||
|
|
|||
|
HGMsgPump msgPump = NULL;
|
|||
|
HGBase_CreateMsgPump(&msgPump);
|
|||
|
|
|||
|
HGThread thread = NULL;
|
|||
|
HGBase_OpenThread(ThreadFunc, msgPump, &thread);
|
|||
|
HGBase_CloseThread(thread);
|
|||
|
thread = NULL;
|
|||
|
|
|||
|
HGBase_DestroyMsgPump(msgPump);
|
|||
|
msgPump = NULL;
|
|||
|
|
|||
|
#if defined(HG_CMP_MSC)
|
|||
|
WSACleanup();
|
|||
|
#endif
|
|||
|
return 0;
|
|||
|
}
|