aboutsummaryrefslogtreecommitdiffstats
path: root/examples/websockets/echoserver/main.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-02-13 11:31:52 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-02-20 11:30:08 +0000
commit8ebed733e872ded507256addf932e19e1b6ed2b6 (patch)
treeddb93e50d4a33468ce4d2cfab503fb060c39e39c /examples/websockets/echoserver/main.cpp
parent85a8ea105646c7d871f982b890ef5f6faa91824d (diff)
Examples: add options for port and debug outputs in echoserver
Change-Id: Iadba1c5cb7cd4454b01a98339c2225483b08e180 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com> Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com> Reviewed-by: Topi Reiniƶ <topi.reinio@digia.com>
Diffstat (limited to 'examples/websockets/echoserver/main.cpp')
-rw-r--r--examples/websockets/echoserver/main.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/examples/websockets/echoserver/main.cpp b/examples/websockets/echoserver/main.cpp
index ed408ae..c433030 100644
--- a/examples/websockets/echoserver/main.cpp
+++ b/examples/websockets/echoserver/main.cpp
@@ -31,12 +31,30 @@
**
****************************************************************************/
#include <QtCore/QCoreApplication>
+#include <QtCore/QCommandLineParser>
+#include <QtCore/QCommandLineOption>
#include "echoserver.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
- EchoServer *server = new EchoServer(1234);
+
+ QCommandLineParser parser;
+ parser.setApplicationDescription("QtWebSockets example: echoserver");
+ parser.addHelpOption();
+
+ QCommandLineOption dbgOption(QStringList() << "d" << "debug",
+ QCoreApplication::translate("main", "Debug output [default: off]."));
+ parser.addOption(dbgOption);
+ QCommandLineOption portOption(QStringList() << "p" << "port",
+ QCoreApplication::translate("main", "Port for echoserver [default: 1234]."),
+ QCoreApplication::translate("main", "port"), QLatin1Literal("1234"));
+ parser.addOption(portOption);
+ parser.process(a);
+ bool debug = parser.isSet(dbgOption);
+ int port = parser.value(portOption).toInt();
+
+ EchoServer *server = new EchoServer(port, debug);
QObject::connect(server, &EchoServer::closed, &a, &QCoreApplication::quit);
return a.exec();