summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-02-15 21:17:21 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-02-15 21:17:21 +0100
commita9bad172f62fe1dda280df5477a8b7c1bd57690d (patch)
treea22948b7300a57902a6e46d5346104e32c898e64 /examples
parent9507cdc31ff6778cba77764bb0991e538c493a9e (diff)
parente777ff1f88e58c1b47044ac83aafa8ccafa3840f (diff)
downloadqtwebchannel-a9bad172f62fe1dda280df5477a8b7c1bd57690d.tar.gz
Merge remote-tracking branch 'origin/5.6' into 5.7v5.7.0-alpha1
Conflicts: .qmake.conf Change-Id: I42bfb38e5a9bf03b43636309fe9e29e8d772bb06
Diffstat (limited to 'examples')
-rw-r--r--examples/webchannel/standalone/index.html6
-rw-r--r--examples/webchannel/standalone/main.cpp10
2 files changed, 12 insertions, 4 deletions
diff --git a/examples/webchannel/standalone/index.html b/examples/webchannel/standalone/index.html
index 778a502..b5a9a49 100644
--- a/examples/webchannel/standalone/index.html
+++ b/examples/webchannel/standalone/index.html
@@ -11,7 +11,11 @@
output.innerHTML = output.innerHTML + message + "\n";
}
window.onload = function() {
- var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]);
+ if (location.search != "")
+ var baseUrl = (/[?&]webChannelBaseUrl=([A-Za-z0-9\-:/\.]+)/.exec(location.search)[1]);
+ else
+ 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 921aa4c..b53e9a6 100644
--- a/examples/webchannel/standalone/main.cpp
+++ b/examples/webchannel/standalone/main.cpp
@@ -55,8 +55,8 @@
#include <QVariantMap>
#include <QDesktopServices>
#include <QUrl>
-#include <QDebug>
-
+#include <QDir>
+#include <QFileInfo>
#include <QtWebSockets/QWebSocketServer>
#include "../shared/websocketclientwrapper.h"
@@ -128,6 +128,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)) {
@@ -149,7 +154,6 @@ int main(int argc, char** argv)
// open a browser window with the client HTML page
QUrl url = QUrl::fromLocalFile(BUILD_DIR "/index.html");
- url.setQuery(QStringLiteral("webChannelBaseUrl=") + server.serverUrl().toString());
QDesktopServices::openUrl(url);
dialog.displayMessage(QObject::tr("Initialization complete, opening browser at %1.").arg(url.toDisplayString()));