forked from andsfonseca/dota2-rpc-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
74 lines (65 loc) · 1.7 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#if defined(_WIN32) || defined(_WIN64)
#include <Windows.h>
#include "third_party/SrvLib/Service.h"
#pragma comment(lib, "SrvLib.lib")
#else
#include <codecvt>
#include <locale>
#include <syslog.h>
#include <unistd.h>
#endif
#include <managers/ConfigurationManager.h>
#include <managers/LanguageManager.h>
#include <managers/SteamManager.h>
#include <managers/WebServerManager.h>
enum ArgumentOptions
{
NONE,
INSTALL,
};
ArgumentOptions resolveArgumentOption(const std::string input)
{
if (input == "-i" || input == "--install")
return INSTALL;
return NONE;
}
void readArgs(const int argc, const char *argv[])
{
if (argc > 1)
{
switch (resolveArgumentOption(argv[1]))
{
case INSTALL:
SteamManager::onInstall();
break;
default:
break;
}
}
}
int main(int argc, const char *argv[])
{
readArgs(argc, argv);
#if defined(_WIN32) || defined(_WIN64)
SrvParam svParam;
#if defined(_WIN32) || defined(_WIN64)
svParam.szDspName = L"Dota 2 RPC Client Service"; // Servicename in Service control manager of windows
svParam.szDescrip = L"Dota 2 RPC Client Service"; // Description in Service control manager of windows
#endif
svParam.szSrvName = L"dota2rpc"; // Service name (service id)
svParam.fnStartCallBack = WebServerManager::start;
svParam.fnStopCallBack = WebServerManager::stop;
svParam.fnSignalCallBack = []() {
};
// No option, run sync
// if (argc <= 1)
// {
// const char *args[] = {"", "-f"};
// return ServiceMain(2, args, svParam);
// }
return ServiceMain(argc, argv, svParam);
#else
WebServerManager::onStart();
return 0;
#endif
}