[Development] QWebSockets: Advice wanted on API

Shane Kearns shane.kearns.qt at gmail.com
Mon Oct 28 21:37:42 CET 2013


Using QSslConfiguration exclusively is a good idea, and removes most of the
QSslSocket functions.

Also consider which functions / signals are handled internal to websocket.
e.g. encrypted, encryptedBytesWritten may be internal since websocket is
message based.
If the handling of the signal is always going to be the same, keep it
internal rather than making people write boilerplate.
If there's an application specific policy then forward the signal.
Other signals / slots need to be forwarded (e.g. sslErrors is required to
display detailed error information).

Where appropriate, you can have default implementation for the most common
case, and do that if the signal is not connected.

I'd favour one class, and use the ws: or wss: schema to decide what do to
internally. You can document which APIs only apply to wss.
This is analogous to http and https being handled by the same api.


On 27 October 2013 10:35, Thiago Macieira <thiago.macieira at intel.com> wrote:

> On domingo, 27 de outubro de 2013 11:07:39, Kurt Pattyn wrote:
> > Hi,
> >
> > I would like to add secure sockets support to the QWebSocket class (see
> > QtWebSockets add-on at https://qt.gitorious.org/qtplayground/websockets
> ).
> > Currently, a connection is made to a web socket server, as follows:
> > QWebSocket webSocket;
> >       webSocket.open(QUrl(“ws://someserver”));
> >
> > Internally, a QTcpSocket is created to set up the connection.
> >
> > Now, I have 3 options to add secure web sockets:
> > 1. Use a QSslSocket internally when the scheme of the URL is wss.
> > This would imply that all or most of the SSL related functionality of
> > QSslSocket should be exposed from the QWebSockets class
> > (addCaCertificate(), …), making the QWebSocket API quite humongous.
>
> That's what QSslConfiguration is for. No cluttering the API, just two
> functions.
>
> > 3. Use an IOC principle
> > Supply a QTcpSocket or a QSslSocket to the constructor of QWebSocket.
>
> That might be interesting, depending on whether we want a pre-connected
> socket. But it shouldn't be the default way that people would use to
> connect.
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131028/9eeeb858/attachment.html>


More information about the Development mailing list