From 46ce17f7fc7a234abde21e09e21dd68527ff8734 Mon Sep 17 00:00:00 2001 From: Akira Ohgaki <akiraohgaki@gmail.com> Date: Fri, 28 Apr 2017 18:47:46 +0900 Subject: [PATCH] Add port option --- app/src/main.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main.cpp b/app/src/main.cpp index 9bab403..3c942ee 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(); } -- GitLab