readyRead in QWebSocket
-
QWebSocket directly derives from QTcpSocket. -> ReadyRead does work
see here: https://forum.qt.io/topic/106325/readyread-in-qwebsocket/6
-
@j-hilk said in readyRead in QWebSocket:
QWebSocket directly derives from QTcpSocket
No per online documentation
Inherits: QObject
ReadyRead does work
Have you really tried it?
Again, from online documentation there's no signal readyRead() at all... -
@pablo-j-rogina
per source code it doesQWebSocketPrivate::QWebSocketPrivate(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version, QWebSocket *pWebSocket) : QObjectPrivate(), q_ptr(pWebSocket), m_pSocket(pTcpSocket), m_errorString(pTcpSocket->errorString()), m_version(version), m_resourceName(), m_request(), m_origin(), m_protocol(), m_extension(), m_socketState(pTcpSocket->state()), m_pauseMode(pTcpSocket->pauseMode()), m_readBufferSize(pTcpSocket->readBufferSize()), m_key(), m_mustMask(true), m_isClosingHandshakeSent(false), m_isClosingHandshakeReceived(false), m_closeCode(QWebSocketProtocol::CloseCodeNormal), m_closeReason(), m_pingTimer(), m_dataProcessor(), m_configuration(), m_pMaskGenerator(&m_defaultMaskGenerator), m_defaultMaskGenerator(), m_handshakeState(NothingDoneState) { }
It's from the private web socket class part so it may change in the future, but currently it is
and no, I haven't tried.
No example at hand right now
But I concur, going through the publicly available functions and signals, readyRead is indeed not forwarded. Interesting 🤔
-
@mikeeeeee you may want to look at this example.
You may need to think using a slightly different approach, with signals like connected(), disconnected(), binaryMessageReceived(), textMessageReceived() and so on.
-
@j-hilk said in readyRead in QWebSocket:
per source code it does
No, it does not
The source code snippet you posted clearly shows that QWebSocketPrivate class (the underlying implementation for QWebSocket) has QTcpSocket as a member, but it doesn't derive from it.
QWebSocketPrivate::QWebSocketPrivate(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version, QWebSocket *pWebSocket) : QObjectPrivate(), ... m_pSocket(pTcpSocket), ...
And keeping on looking at source code, you'll find out that the QTcpSocket::readyRead() signal is "hidden" in the QWebsocketPrivate class, as it is handled internally
QObjectPrivate::connect(pTcpSocket, &QAbstractSocket::readyRead, this, &QWebSocketPrivate::processData, Qt::QueuedConnection);
-
@pablo-j-rogina
jup, I agree, my initial statement was incorrect