[Development] network protocol patterns

Richard Gerd Kuesters richard at humantech.com.br
Tue Aug 20 20:52:28 CEST 2013


Hello all!

I was reading this interesting thread, still fresh:

http://lists.qt-project.org/pipermail/development/2013-August/012492.html

And I have to say is that I'm very interested in how developers can use 
resources that already exists in the Qt framework, specially about 
networking.

An example: some time ago, I needed to start refactoring an application 
(that uses Qt + WebKit) to load content from an arbitrary source - a 
local database, as example. So, to have an webkit desktop based 
application that talks to the web and still communicate to the web, I 
got to get rid of setHtml("...") and stuff; and I did it by "creating my 
own scheme" on QNetworkAccessManager. It is hosted on github:

https://github.com/vltr/webkit-scheme-qt5.1

By doing this, I can develop the application's content using 
Chrome/Safari and then just wrap it into a database. VoilĂ !

Ok, that was the easy part. Now the "thing" that is preventing me from 
sleep: since I'm making it all (the javascript / html / css) in a 
"transparent way", I would like also to send signals to my (client) 
application. I know I can call a JavaScript function from inside WebKit, 
but instead of that I wanted to "mock" the response of a websocket. 
Since my client will always be the same, I can't worry much about "will 
it work" and have the same transparent layer of code to write outside 
the Qt + Webkit structure.

The question is: how would I mock a simple websocket? One thing I (may) 
know: it should be by using the QIODevice, lol. If my line of thought is 
right, I can write a QIODevice that provides frames for the websocket, 
reading my application's custom signals and sending them to the 
"client". It should also never send the close signal (am I right?). The 
problem is: can it be made in a simple way? And, if this "simple way" 
exists, would it block my client and then should be run on a separate 
thread?

As I know there are tons of the most diverse implementations out there, 
maybe someone could give me a hint.


My best regards,
Richard.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130820/42d1447a/attachment.html>


More information about the Development mailing list