Skip to content
Snippets Groups Projects
Commit 6652af19 authored by akiraohgaki's avatar akiraohgaki
Browse files

49152 as default port

parent 97676733
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QCommandLineOption> #include <QCommandLineOption>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug>
#include "handlers/confighandler.h" #include "handlers/confighandler.h"
//#include "handlers/systemhandler.h" //#include "handlers/systemhandler.h"
...@@ -36,17 +37,24 @@ int main(int argc, char *argv[]) ...@@ -36,17 +37,24 @@ int main(int argc, char *argv[])
clParser.setApplicationDescription(appConfigApplication["description"].toString()); clParser.setApplicationDescription(appConfigApplication["description"].toString());
clParser.addHelpOption(); clParser.addHelpOption();
clParser.addVersionOption(); clParser.addVersionOption();
QCommandLineOption clPortOption(QStringList() << "p" << "port", "Port for websocket server [default: 443].", "port", "443");
clParser.addOption(clPortOption); // Port 49152-61000 will available as ephemeral port
// https://en.wikipedia.org/wiki/Ephemeral_port
QCommandLineOption clOptionPort(QStringList() << "p" << "port", "Port for websocket server [default: 49152].", "port", "49152");
clParser.addOption(clOptionPort);
clParser.process(app); clParser.process(app);
int port = clParser.value(clPortOption).toInt(); int port = clParser.value(clOptionPort).toInt();
// Setup websocket server // Setup websocket server
WebSocketServer *webSocketServer = new WebSocketServer(appConfigApplication["id"].toString(), port, &app); WebSocketServer *webSocketServer = new WebSocketServer(appConfigApplication["id"].toString(), port, &app);
if (!webSocketServer->start()) { if (!webSocketServer->start()) {
qFatal(webSocketServer->errorString()); qCritical() << "Failed to start websocket server:" << webSocketServer->errorString();
return 1;
} }
qDebug() << "Websocket server started at:" <<webSocketServer->serverUrl().toString();
return app.exec(); return app.exec();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment