summaryrefslogtreecommitdiff
path: root/src/imports
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2014-02-05 17:44:03 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-21 15:59:25 +0100
commit48e814442e6e8507aacd16362b44d5754c059228 (patch)
tree592f3916bf2e5dc18d57a62c3baf1ba0ae2bbf09 /src/imports
parente3e4d6a18d63537459f0e616360e53e816927f76 (diff)
downloadqtwebchannel-48e814442e6e8507aacd16362b44d5754c059228.tar.gz
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 <simon.hausmann@digia.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/webchannel/qmlwebviewtransport.cpp8
-rw-r--r--src/imports/webchannel/qmlwebviewtransport.h4
2 files changed, 6 insertions, 6 deletions
diff --git a/src/imports/webchannel/qmlwebviewtransport.cpp b/src/imports/webchannel/qmlwebviewtransport.cpp
index 7fb9d16..3d4e2ed 100644
--- a/src/imports/webchannel/qmlwebviewtransport.cpp
+++ b/src/imports/webchannel/qmlwebviewtransport.cpp
@@ -74,7 +74,7 @@ QObject *QmlWebViewTransport::webViewExperimental() const
return m_webViewExperimental;
}
-void QmlWebViewTransport::sendMessage(const QString &message) const
+void QmlWebViewTransport::sendMessage(const QString &message, int /*clientId*/) const
{
if (!m_webViewExperimental) {
qWarning("Cannot send message - did you forget to set the webViewExperimental property?");
@@ -83,16 +83,16 @@ void QmlWebViewTransport::sendMessage(const QString &message) const
QMetaObject::invokeMethod(m_webViewExperimental, "postMessage", Q_ARG(QString, message));
}
-void QmlWebViewTransport::sendMessage(const QByteArray &message) const
+void QmlWebViewTransport::sendMessage(const QByteArray &message, int clientId) const
{
- sendMessage(QString::fromUtf8(message));
+ sendMessage(QString::fromUtf8(message), clientId);
}
void QmlWebViewTransport::handleWebViewMessage(const QVariantMap &message)
{
if (m_handler) {
const QString &data = message[QStringLiteral("data")].toString();
- m_handler->handleMessage(data);
+ m_handler->handleMessage(data, this, -1);
emit messageReceived(data);
}
}
diff --git a/src/imports/webchannel/qmlwebviewtransport.h b/src/imports/webchannel/qmlwebviewtransport.h
index 98dc504..bb1e27e 100644
--- a/src/imports/webchannel/qmlwebviewtransport.h
+++ b/src/imports/webchannel/qmlwebviewtransport.h
@@ -55,8 +55,8 @@ public:
explicit QmlWebViewTransport(QObject *parent = 0);
~QmlWebViewTransport() Q_DECL_OVERRIDE;
- void sendMessage(const QString &message) const Q_DECL_OVERRIDE;
- void sendMessage(const QByteArray &message) const Q_DECL_OVERRIDE;
+ void sendMessage(const QString &message, int clientId) const Q_DECL_OVERRIDE;
+ void sendMessage(const QByteArray &message, int clientId) const Q_DECL_OVERRIDE;
void setMessageHandler(QWebChannelMessageHandlerInterface *handler) Q_DECL_OVERRIDE;
void setWebViewExperimental(QObject *webViewExperimental);