Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved readyRead in QWebSocket

    General and Desktop
    3
    7
    287
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mikeeeeee last edited by

      Hi!
      In QTcpSocket work signal readyRead , but in QWebSocket this signal not work. How to replace this signal?

      J.Hilk Pablo J. Rogina 2 Replies Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @Mikeeeeee last edited by J.Hilk

        QWebSocket directly derives from QTcpSocket. -> ReadyRead does work


        see here: https://forum.qt.io/topic/106325/readyread-in-qwebsocket/6

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        Pablo J. Rogina 1 Reply Last reply Reply Quote 0
        • Pablo J. Rogina
          Pablo J. Rogina @J.Hilk last edited by

          @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...

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          J.Hilk 1 Reply Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @Pablo J. Rogina last edited by J.Hilk

            @pablo-j-rogina
            per source code it does

            QWebSocketPrivate::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 🤔

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            Pablo J. Rogina 1 Reply Last reply Reply Quote 0
            • Pablo J. Rogina
              Pablo J. Rogina @Mikeeeeee last edited by

              @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.

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply Reply Quote 0
              • Pablo J. Rogina
                Pablo J. Rogina @J.Hilk last edited by

                @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);
                

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                J.Hilk 1 Reply Last reply Reply Quote 0
                • J.Hilk
                  J.Hilk Moderators @Pablo J. Rogina last edited by

                  @pablo-j-rogina
                  jup, I agree, my initial statement was incorrect

                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

                  Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post