Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt gRPC - get return value of a call asyncronously
Qt 6.11 is out! See what's new in the release blog

Qt gRPC - get return value of a call asyncronously

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 727 Views 1 Watching
  • 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 Offline
    M Offline
    martonmiklos
    wrote on last edited by
    #1

    Hello all,

    I have an RPC call (StartStream) defined here:
    https://github.com/saleae/logic2-automation/blob/develop/proto/saleae/grpc/saleae.proto#L36

    it returns a StartCaptureReply.

    The qtgrpcgen tool generates the following API:

    QGrpcStatus StartCapture(const saleae::automation::StartCaptureRequest &arg, saleae::automation::StartCaptureReply *ret);
        std::shared_ptr<QGrpcCallReply> StartCapture(const saleae::automation::StartCaptureRequest &arg);
        Q_INVOKABLE void StartCapture(const saleae::automation::StartCaptureRequest &arg, const QObject *context, const std::function<void(std::shared_ptr<QGrpcCallReply>)> &callback);
    

    I use the following code to call the StartCapture:

    auto reply = m_client->StartCapture(req);
        reply->subscribe(this,
            [this]() {
                finishExecution(true);
            },
            [this](const QGrpcStatus &status) {
                grpcErrorOccurred(status);
            });
    

    Is there any way to get access to the StartCaptureReply in the slot attached to the QGrpcCallReply::finished signal (attached by the subscribe)?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since the callback is a lambda, why don't you pass the reply to it the same way you do for this ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved