-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
34 lines (27 loc) · 1.02 KB
/
main.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
27
28
29
30
31
32
33
34
#include <QCoreApplication>
#include <QWebChannel>
#include <QWebSocket>
#include <QWebSocketServer>
#include "shared/websocketclientwrapper.h"
#include "shared/websockettransport.h"
#include "hasher.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
// setup the QWebSocketServer
QWebSocketServer server(QStringLiteral("QWebChannel Standalone Example Server"), QWebSocketServer::NonSecureMode);
if (!server.listen(QHostAddress::LocalHost, 12345)) {
qFatal("Failed to open web socket server.");
return 1;
}
// wrap WebSocket clients in QWebChannelAbstractTransport objects
WebSocketClientWrapper clientWrapper(&server);
// setup the channel
QWebChannel channel;
QObject::connect(&clientWrapper, &WebSocketClientWrapper::clientConnected,
&channel, &QWebChannel::connectTo);
// setup the dialog and publish it to the QWebChannel
Hasher hasher;
channel.registerObject(QStringLiteral("hasher"), &hasher);
return app.exec();
}