ProudNet 은 게임서버를 윈도우 서비스에 등록할 수 있는 간편한 API 모듈을 제공합니다.
윈도우 서비스는 오랜 시간 동작하며 특정한 기능을 수행하는 프로세스입니다. 보통 마이크로소프트 윈도우 운영체제가 시동될 때 실행되며 컴퓨터 사용자가 로그온 하지 않은 상태에서도 실행되는 특징이 있습니다. 그리고 윈도우가 실행되고 있는 한 백그라운드 모드에서 실행됩니다. 이것은 유닉스의 데몬과도 개념이 비슷합니다.
1. 개요
- NTService.exe [-install | -uninstall]
2. 옵션
- -install 과 -uninstall 옵션은 기본적으로 윈도우 서비스 등록과 해제를 위한 것입니다.
3. 실행화면
Windows Service에 등록된 샘플 프로그램
4. 등록모듈 작성 예제코드
#include "stdafx.h"
#include "../../include/ProudNetServer.h"
#include "../../include/NTService.h"
#include "conio.h"
using namespace Proud;
using namespace std;
int g_ServerPort = 33334;
{
public:
virtual void Log(int type, LPCWSTR text)
{
_tprintf(L"%s\n", text);
}
virtual void Pause()
{
printf("pause");
}
virtual void Stop()
{
printf("stop");
}
virtual void Continue()
{
printf("continue");
}
virtual void Run()
{
bool result = srv->
Start(p1, err);
if (result == false)
{
delete srv;
return;
}
puts("Game Server started.\n");
while (1)
{
Sleep(100);
if (_kbhit())
{
int ch = _getch();
switch (ch)
{
case 27:
return;
}
}
MSG msg;
MsgWaitForMultipleObjects(0, 0, TRUE, 100, QS_ALLEVENTS);
if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!GetMessage(&msg, NULL, NULL, NULL))
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
CMySvrEvent g_svrEvent;
int wmain(int argc, WCHAR* argv[], WCHAR* envp[])
{
int nRetCode = 0;
return nRetCode;
}
- 본 예제와 관련된 윈도우용 소스 파일은 <설치 폴더>/Sample/NTService 를 참고하십시오.
5. NTService 활용하기