summaryrefslogtreecommitdiff
path: root/examples/webchannel
diff options
context:
space:
mode:
authorVenugopal Shivashankar <venugopal.shivashankar@digia.com>2016-01-08 14:54:47 +0100
committerVenugopal Shivashankar <venugopal.shivashankar@digia.com>2016-01-14 09:40:56 +0000
commiteaebf63c17964d449b75b7d2d6af3d0efaee5ed9 (patch)
tree2f3afbe459b90d904e925120a264bf42d88d0771 /examples/webchannel
parente82b9c37609ab8f686a6dfd312bf0423bb740f35 (diff)
downloadqtwebchannel-eaebf63c17964d449b75b7d2d6af3d0efaee5ed9.tar.gz
Example: Add code to copy the JS file from the resource system
The JS file lives in the src/webchannel directory, and there is a QMake magic in place to copy it to the build directory. But this mechanism fails when the example is run from the Qt binary pkg, which does not include the sources. The JS file must be copied to the build directory either manually or programmatically to run the example. Change-Id: Ib56d9348a8bf1a599e2db5235e0545cd7a8f3bb1 Task-number: QTBUG-46541 Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'examples/webchannel')
-rw-r--r--examples/webchannel/standalone/index.html3
-rw-r--r--examples/webchannel/standalone/main.cpp9
2 files changed, 9 insertions, 3 deletions
diff --git a/examples/webchannel/standalone/index.html b/examples/webchannel/standalone/index.html
index cc3d72d..b5a9a49 100644
--- a/examples/webchannel/standalone/index.html
+++ b/examples/webchannel/standalone/index.html
@@ -14,7 +14,8 @@
if (location.search != "")
var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]);
else
- var baseUrl = "ws://localhost:12345");
+ var baseUrl = "ws://localhost:12345";
+
output("Connecting to WebSocket server at " + baseUrl + ".");
var socket = new WebSocket(baseUrl);
diff --git a/examples/webchannel/standalone/main.cpp b/examples/webchannel/standalone/main.cpp
index 9c03370..bd2b0a9 100644
--- a/examples/webchannel/standalone/main.cpp
+++ b/examples/webchannel/standalone/main.cpp
@@ -38,8 +38,8 @@
#include <QVariantMap>
#include <QDesktopServices>
#include <QUrl>
-#include <QDebug>
-
+#include <QDir>
+#include <QFileInfo>
#include <QtWebSockets/QWebSocketServer>
#include "../shared/websocketclientwrapper.h"
@@ -111,6 +111,11 @@ int main(int argc, char** argv)
{
QApplication app(argc, argv);
+ QFileInfo jsFileInfo(QDir::currentPath() + "/qwebchannel.js");
+
+ if (!jsFileInfo.exists())
+ QFile::copy(":/qtwebchannel/qwebchannel.js",jsFileInfo.absoluteFilePath());
+
// setup the QWebSocketServer
QWebSocketServer server(QStringLiteral("QWebChannel Standalone Example Server"), QWebSocketServer::NonSecureMode);
if (!server.listen(QHostAddress::LocalHost, 12345)) {