From 48e814442e6e8507aacd16362b44d5754c059228 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Wed, 5 Feb 2014 17:44:03 +0100 Subject: Send response data only to target client. Before, the response was sent to all clients in a broad-cast and had to be filtered on the client-side. This required additional client identification data to be added to all requests and responses. Now, we keep track of the transport and transport-internal client and only send the response to that client. This is very benefitial for multi-client setups but also reduces traffic for single-client setups and thus their performance. Change-Id: Ia1ef5e031b0058222083d352a8aa28a7d566a6ca Reviewed-by: Simon Hausmann --- tests/qml/data/respond.html | 17 ----------------- tests/qml/tst_webchannel.qml | 10 ---------- tests/webchannel/tst_webchannel.cpp | 6 +++--- tests/webchannel/tst_webchannel.h | 4 ++-- 4 files changed, 5 insertions(+), 32 deletions(-) delete mode 100644 tests/qml/data/respond.html (limited to 'tests') diff --git a/tests/qml/data/respond.html b/tests/qml/data/respond.html deleted file mode 100644 index 5f0e7fc..0000000 --- a/tests/qml/data/respond.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - diff --git a/tests/qml/tst_webchannel.qml b/tests/qml/tst_webchannel.qml index 160a1af..dddba71 100644 --- a/tests/qml/tst_webchannel.qml +++ b/tests/qml/tst_webchannel.qml @@ -56,14 +56,4 @@ WebChannelTest { webChannel.sendMessage("myMessage", "foobar"); compare(awaitRawMessage(), "myMessagePong:foobar"); } - - function test_respondMessage() - { - loadUrl("respond.html"); - var msg = awaitMessage(); - verify(msg.id); - compare(msg.data, "foobar"); - webChannel.respond(msg.id, "barfoo"); - compare(awaitRawMessage(), "received:barfoo"); - } } diff --git a/tests/webchannel/tst_webchannel.cpp b/tests/webchannel/tst_webchannel.cpp index bb08c21..ece02a8 100644 --- a/tests/webchannel/tst_webchannel.cpp +++ b/tests/webchannel/tst_webchannel.cpp @@ -242,19 +242,19 @@ void TestWebChannel::testInvokeMethodConversion() { int method = metaObject()->indexOfMethod("setInt(int)"); QVERIFY(method != -1); - QVERIFY(channel.d->publisher->invokeMethod(this, method, args, QJsonValue())); + QVERIFY(!channel.d->publisher->invokeMethod(this, method, args, QJsonValue()).isEmpty()); QCOMPARE(m_lastInt, args.at(0).toInt()); } { int method = metaObject()->indexOfMethod("setDouble(double)"); QVERIFY(method != -1); - QVERIFY(channel.d->publisher->invokeMethod(this, method, args, QJsonValue())); + QVERIFY(!channel.d->publisher->invokeMethod(this, method, args, QJsonValue()).isEmpty()); QCOMPARE(m_lastDouble, args.at(0).toDouble()); } { int method = metaObject()->indexOfMethod("setVariant(QVariant)"); QVERIFY(method != -1); - QVERIFY(channel.d->publisher->invokeMethod(this, method, args, QJsonValue())); + QVERIFY(!channel.d->publisher->invokeMethod(this, method, args, QJsonValue()).isEmpty()); QCOMPARE(m_lastVariant, args.at(0).toVariant()); } } diff --git a/tests/webchannel/tst_webchannel.h b/tests/webchannel/tst_webchannel.h index 26aa913..314fe99 100644 --- a/tests/webchannel/tst_webchannel.h +++ b/tests/webchannel/tst_webchannel.h @@ -56,9 +56,9 @@ public: {} ~DummyTransport() {}; - void sendMessage(const QString &/*message*/) const Q_DECL_OVERRIDE + void sendMessage(const QString &/*message*/, int /*clientId*/) const Q_DECL_OVERRIDE {} - void sendMessage(const QByteArray &/*message*/) const Q_DECL_OVERRIDE + void sendMessage(const QByteArray &/*message*/, int /*clientId*/) const Q_DECL_OVERRIDE {} void setMessageHandler(QWebChannelMessageHandlerInterface * /*handler*/) Q_DECL_OVERRIDE {} -- cgit v1.2.1