-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
63 lines (51 loc) · 1.69 KB
/
main.cpp
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
#include <QCoreApplication>
#include <QDebug>
#include <QTimer>
#include "consolereaderthread.h"
#include "DataBrokers/databroker.h"
#include "DataBrokers/filebroker.h"
#include "MessageHandlers/lugameserverhandler.h"
#include "MessageHandlers/luauthserverhandler.h"
#include "luserver.h"
#include "logger.h"
#include "GameLogic/gamelogic.h"
int main(int argc, char *argv[])
{
QTextStream* logger = new QTextStream(stdout);
CURRENT_LOG_LEVEL = LOG_LEVEL::DEBUG;
QCoreApplication app(argc, argv);
DataBroker::setSharedInstance(new FileBroker(&app));
DATABROKER->setLogger(logger);
GAMELOGIC->setLogger(logger);
LUServer authServer("3.25 ND1", new LUAuthServerHandler(DATABROKER->authServerName(), logger), logger, &app);
LUServer gameServer("3.25 ND1", new LUGameServerHandler("GAME", logger), logger, &app);
INFO(logger, "Starting authentication server...");
if(!authServer.startup(DATABROKER->authServerPort(), 10, 3))
{
WARN(logger, "Unable to start authentication server, exiting...");
exit(1);
}
if(!gameServer.startup(DATABROKER->worldServerPort(), 10, 3))
{
WARN(logger, "Unable to start world server, exiting...");
exit(1);
}
ConsoleReader serverIn;
serverIn.start();
QObject::connect(&serverIn, &ConsoleReader::gotLine,
[&app, &authServer, &gameServer, &serverIn](QString line)
{
if(line == "quit")
{
QTimer::singleShot(1, &app, &QCoreApplication::quit);
serverIn.stop();
}
});
int out = app.exec();
authServer.shutdown(1000);
gameServer.shutdown(1000);
delete logger;
delete DATABROKER;
delete GAMELOGIC;
return out;
}