diff --git a/app/src/main.cpp b/app/src/main.cpp index 9bab403a30620dd99a260f3a9809f4a7d0922d17..3c942ee932fc7a1c8115035d601b30bbf135538d 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -1,13 +1,15 @@ +#include <QStringList> #include <QJsonObject> //#include <QTranslator> //#include <QLocale> #include <QCommandLineParser> +#include <QCommandLineOption> #include <QCoreApplication> #include "handlers/confighandler.h" -#include "handlers/systemhandler.h" -#include "handlers/ocshandler.h" -#include "handlers/itemhandler.h" +//#include "handlers/systemhandler.h" +//#include "handlers/ocshandler.h" +//#include "handlers/itemhandler.h" #include "websockets/websocketserver.h" int main(int argc, char *argv[]) @@ -34,11 +36,17 @@ int main(int argc, char *argv[]) clParser.setApplicationDescription(appConfigApplication["description"].toString()); clParser.addHelpOption(); clParser.addVersionOption(); + QCommandLineOption clPortOption(QStringList() << "p" << "port", "Port for websocket server [default: 443].", "port", "443"); + clParser.addOption(clPortOption); clParser.process(app); + int port = clParser.value(clPortOption).toInt(); + // Setup websocket server - WebSocketServer *webSocketServer = new WebSocketServer(appConfigApplication["id"].toString(), 443, &app); - webSocketServer->start(); + WebSocketServer *webSocketServer = new WebSocketServer(appConfigApplication["id"].toString(), port, &app); + if (!webSocketServer->start()) { + qFatal("Failed to start websocket server"); + } return app.exec(); }