[Development] QWebSockets: Advice wanted on API

Sorvig Morten Morten.Sorvig at digia.com
Tue Oct 29 11:49:27 CET 2013


I’d like to second (third?) going for approach 1.

It’s possible that we would want to implement secure socket support for QWebSocket using native API instead of QTcpSocket
and OpenSSL at some point. We are currently doing this for QNetworkAccessManager on OS X and iOS (https://codereview.qt-project.org/#change,69298).

Keeping the QWebSocket API high level and message-based would make this easier.

Morten


On 28 Oct 2013, at 21:37, Shane Kearns <shane.kearns.qt at gmail.com> wrote:

> 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
> 
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development




More information about the Development mailing list