forked from eSKond/QuikQtBridge
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqtmain.cpp
26 lines (25 loc) · 1008 Bytes
/
qtmain.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
#include <QCoreApplication>
#include <QDebug>
#include "quikqtbridge.h"
#include "bridgetcpserver.h"
#include "serverconfigreader.h"
int qtMain(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_PluginApplication, true);
QCoreApplication app(argc, argv);
QString scriptPath = app.arguments().at(0);
ServerConfigReader cfgrdr(scriptPath);
qDebug() << "Create server...";
BridgeTCPServer server;
server.setAllowedIPs(cfgrdr.getAllowedIPs());
server.setLogPathPrefix(cfgrdr.getLogPathPrefix());
server.setDebugLogPathPrefix(cfgrdr.getDebugLogPathPrefix());
qDebug() << "start listening on " << cfgrdr.getHost() << ":" << cfgrdr.getPort();
if(server.listen(cfgrdr.getHost(), cfgrdr.getPort()))
qDebug() << "Server started on:" << server.serverAddress().toString() << ":" << server.serverPort();
qDebug() << "start app event loop...";
int res = app.exec();
qDebug() << "app event loop finished.";
server.close();
return res;
}