code_app/sdk/webscan/main.cpp

60 lines
1.3 KiB
C++
Raw Normal View History

2022-09-06 08:27:58 +00:00
#include "base/HGDef.h"
#include "base/HGInc.h"
#include "base/HGThread.h"
#include "base/HGMsgPump.h"
#include "base/HGUtility.h"
#include "base/HGIni.h"
2022-09-06 08:27:58 +00:00
#include "WebServer.h"
#include "MsgPumpCallback.h"
#include "lang/app_language.h"
2022-09-06 08:27:58 +00:00
static void HGAPI ThreadFunc(HGThread thread, HGPointer param)
2022-09-06 08:27:58 +00:00
{
(void)thread;
HGMsgPump msgPump = (HGMsgPump)param;
HGChar cfgPath[256];
HGBase_GetConfigPath(cfgPath, 256);
HGChar cfgName[256];
sprintf(cfgName, "%s%s", cfgPath, "config.ini");
2022-09-06 08:27:58 +00:00
WebServer wsServer(msgPump);
//HGInt port = 9458;
HGInt port = 23165;
HGBase_GetProfileInt(cfgName, "connect", "port", 23165, &port);
2022-09-06 08:27:58 +00:00
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;
}