[Development] Distinguish clients connected to QtWebChannel

Milian Wolff milian.wolff at kdab.com
Fri Jul 4 20:48:38 CEST 2014

On Friday 04 July 2014 15:44:30 Lutz Schönemann wrote:
> Hi,
> inspecting the QtWebChannel code I found that a QMetaObjectPublisher
> object is not able to distinquish between different clients.

It can distinguish between different clients, but it's not optimal.

> In my eyes
> that is a critical part that is needed to support multiple clients
> connected to a single QWebChannel.

I don't think its critical, but it would certainly be nice to have. Please 
remember, the critical use-case is publishing objects to a WebView or 
WebEngineView. You rarely have more than one of those. And with the proposed 
WebKit integration [1], you'd even get one webchannel per WebView.

[1]: https://codereview.qt-project.org/#/c/89086/

> Because of that reason the feature that property updates are only send
> if the client is idling is not working correctly. Imagine two clients
> connected to a web channel get a bunch of property updates. The first
> client finished processing and sends a "idle-message" to signal that he
> is able to receive the next update. The second client is still
> processing the first bunch of property changes but will receive the next
> update regardless of whether it is able to process it or not. That could
> lead to clients that are out of sync.

No, they are not out-of-sync. The worst-case scenario is that you'll end up 
with clients that are getting spammed with messages and cannot react on 
incoming requests. See my other mail on that bit of history. Anyhow, if you'd 
track property updates on a per-client basis, you could also simply use a 
single webchannel per client (see above).

And one more note on the out-of-sync: Well, so what if clients are out-of-
sync? There's no guarantee _at all_ that clients are in-sync. Quite the 
contrary, the whole thing is highly asynchronous and thus you can never assume 
that when one client saw a property update, the other one did so as well.

> Also a client can disconnect from a signal but because of not being able
> to distinguish the clients all clients will not receive that signal anymore.

That certainly is a bug. Please report it and assign it to me. Which reminds 
me - do we have a QtWebChannel component on Jira already? If not, what do I 
need to do in order to get one?

> Is it meant to be that way? In my opinion the channel should hold the
> state of every client instead of one state.

Imo, it would be too complicated and would also degrade performance, if you'd 
have to track the property map on a per-client basis. If you do that, simply 
use separate webchannels and be done with it...

Milian Wolff | milian.wolff at kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel. Germany +49-30-521325470, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4773 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140704/1fc34865/attachment.bin>

More information about the Development mailing list