Przeglądaj źródła

Complete stream renaming

- Rename 'subscribe' methods to 'stream'
Alexey Edelev 3 lat temu
rodzic
commit
51b4bca2ad

+ 2 - 2
examples/addressbook/addressbookengine.cpp

@@ -56,11 +56,11 @@ AddressBookEngine::AddressBookEngine() : QObject()
     std::shared_ptr<QtProtobuf::QAbstractGrpcChannel> channel(new QtProtobuf::QGrpcHttp2Channel(QUrl("https://localhost:65001"), QtProtobuf::QGrpcSslCredentials(conf) |
                                                                                       QtProtobuf::QGrpcUserPasswordCredentials<>("authorizedUser", QCryptographicHash::hash("test", QCryptographicHash::Md5).toHex())));
     m_client->attachChannel(channel);
-    auto stream = m_client->subscribeContacts(ListFrame());
+    auto stream = m_client->streamContacts(ListFrame());
     connect(stream.get(), &QtProtobuf::QGrpcStream::messageReceived, this, [this, stream]() {
         m_contacts->reset(stream->read<Contacts>().list());
     });
-    m_client->subscribeCallStatus(qtprotobuf::examples::None(), QPointer<CallStatus>(&m_callStatus));
+    m_client->streamCallStatus(qtprotobuf::examples::None(), QPointer<CallStatus>(&m_callStatus));
 }
 
 void AddressBookEngine::addContact(qtprotobuf::examples::Contact *contact)

+ 1 - 1
examples/simplechat/simplechatengine.cpp

@@ -73,7 +73,7 @@ void SimpleChatEngine::login(const QString &name, const QString &password)
                                                                                       QtProtobuf::QGrpcUserPasswordCredentials<>(name, QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex())));
 
     m_client->attachChannel(channel);
-    QtProtobuf::QGrpcStreamShared stream = m_client->subscribeMessageList(None());
+    QtProtobuf::QGrpcStreamShared stream = m_client->streamMessageList(None());
     QObject::connect(stream.get(), &QtProtobuf::QGrpcStream::error, this, [stream] {
         qCritical() << "Stream error, cancel";
         stream->cancel();

+ 11 - 11
src/generator/templates.cpp

@@ -334,7 +334,7 @@ const char *Templates::ClientMethodDefinitionQmlTemplate = "\nvoid $classname$::
                                                            "        return;\n"
                                                            "    }\n\n"
                                                            "    QtProtobuf::QGrpcAsyncReplyShared reply = call(\"$method_name$\", *$param_name$);\n"
-                                                           "    reply->subscribe(jsEngine, [this, reply, callback, jsEngine]() {\n"
+                                                           "    reply->stream(jsEngine, [this, reply, callback, jsEngine]() {\n"
                                                            "        auto result = new $return_type$(reply->read<$return_type$>());\n"
                                                            "        qmlEngine(this)->setObjectOwnership(result, QQmlEngine::JavaScriptOwnership);\n"
                                                            "        QJSValue(callback).call(QJSValueList{jsEngine->toScriptValue(result)});\n"
@@ -359,7 +359,7 @@ const char *Templates::ClientMethodDefinitionQml2Template = "\nvoid $classname$:
                                                             "        return;\n"
                                                             "    }\n\n"
                                                             "    QtProtobuf::QGrpcAsyncReplyShared reply = call(\"$method_name$\", *$param_name$);\n"
-                                                            "    reply->subscribe(jsEngine, [this, reply, jsEngine, safeReturn]() {\n"
+                                                            "    reply->stream(jsEngine, [this, reply, jsEngine, safeReturn]() {\n"
                                                             "        if (safeReturn.isNull()) {\n"
                                                             "            qProtoWarning() << \"Return value is destroyed. Ignore call result\";\n"
                                                             "            return;\n"
@@ -378,21 +378,21 @@ const char *Templates::QmlRegisterEnumTypeTemplate = "qmlRegisterUncreatableType
 
 
 const char *Templates::ClientMethodSignalDeclarationTemplate = "Q_SIGNAL void $method_name$Updated(const $return_type$ &);\n";
-const char *Templates::ClientMethodServerStreamDeclarationTemplate = "QtProtobuf::QGrpcStreamShared subscribe$method_name_upper$(const $param_type$ &$param_name$);\n";
-const char *Templates::ClientMethodServerStream2DeclarationTemplate = "QtProtobuf::QGrpcStreamShared subscribe$method_name_upper$(const $param_type$ &$param_name$, const QPointer<$return_type$> &$return_name$);\n";
-const char *Templates::ClientMethodServerStreamQmlDeclarationTemplate = "Q_INVOKABLE QtProtobuf::QGrpcStreamShared qmlSubscribe$method_name_upper$_p($param_type$ *$param_name$, $return_type$ *$return_name$);\n";
+const char *Templates::ClientMethodServerStreamDeclarationTemplate = "QtProtobuf::QGrpcStreamShared stream$method_name_upper$(const $param_type$ &$param_name$);\n";
+const char *Templates::ClientMethodServerStream2DeclarationTemplate = "QtProtobuf::QGrpcStreamShared stream$method_name_upper$(const $param_type$ &$param_name$, const QPointer<$return_type$> &$return_name$);\n";
+const char *Templates::ClientMethodServerStreamQmlDeclarationTemplate = "Q_INVOKABLE QtProtobuf::QGrpcStreamShared qmlStream$method_name_upper$_p($param_type$ *$param_name$, $return_type$ *$return_name$);\n";
 
-const char *Templates::ClientMethodServerStreamDefinitionTemplate = "QtProtobuf::QGrpcStreamShared $classname$::subscribe$method_name_upper$(const $param_type$ &$param_name$)\n"
+const char *Templates::ClientMethodServerStreamDefinitionTemplate = "QtProtobuf::QGrpcStreamShared $classname$::stream$method_name_upper$(const $param_type$ &$param_name$)\n"
                                                                     "{\n"
-                                                                    "    return subscribe(\"$method_name$\", $param_name$);\n"
+                                                                    "    return stream(\"$method_name$\", $param_name$);\n"
                                                                     "}\n";
-const char *Templates::ClientMethodServerStream2DefinitionTemplate = "QtProtobuf::QGrpcStreamShared $classname$::subscribe$method_name_upper$(const $param_type$ &$param_name$, const QPointer<$return_type$> &$return_name$)\n"
+const char *Templates::ClientMethodServerStream2DefinitionTemplate = "QtProtobuf::QGrpcStreamShared $classname$::stream$method_name_upper$(const $param_type$ &$param_name$, const QPointer<$return_type$> &$return_name$)\n"
                                                                      "{\n"
-                                                                     "    return subscribe(\"$method_name$\", $param_name$, $return_name$);\n"
+                                                                     "    return stream(\"$method_name$\", $param_name$, $return_name$);\n"
                                                                      "}\n";
-const char *Templates::ClientMethodServerStreamQmlDefinitionTemplate = "QtProtobuf::QGrpcStreamShared $classname$::qmlSubscribe$method_name_upper$_p($param_type$ *$param_name$, $return_type$ *$return_name$)\n"
+const char *Templates::ClientMethodServerStreamQmlDefinitionTemplate = "QtProtobuf::QGrpcStreamShared $classname$::qmlStream$method_name_upper$_p($param_type$ *$param_name$, $return_type$ *$return_name$)\n"
                                                                        "{\n"
-                                                                       "    return subscribe(\"$method_name$\", *$param_name$, QPointer<$return_type$>($return_name$));\n"
+                                                                       "    return stream(\"$method_name$\", *$param_name$, QPointer<$return_type$>($return_name$));\n"
                                                                        "}\n";
 
 const char *Templates::ListSuffix = "Repeated";

+ 3 - 3
src/grpc/qabstractgrpcchannel.h

@@ -78,14 +78,14 @@ public:
     virtual void call(const QString &method, const QString &service, const QByteArray &args, QtProtobuf::QGrpcAsyncReply *ret) = 0;
 
     /*!
-     * \brief Subscribes to server-side stream to receive updates for given \p method.
+     * \brief Streams to server-side stream to receive updates for given \p method.
      *        \note This method should not be called directly.
      * \param[in] method remote method is called
      * \param[in] service service identified in URL path format
      * \param[in] args serialized argument message
      * \param[in] handler callback that will be called when message recevied from the server-stream
      */
-    virtual void subscribe(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client) = 0;
+    virtual void stream(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client) = 0;
 
     virtual std::shared_ptr<QAbstractProtobufSerializer> serializer() const = 0;
 
@@ -107,7 +107,7 @@ protected:
     /*!
      * \private
      * \brief Cancels \p stream
-     * \param[in] stream returned by QAbstractGrpcChannel::subscribe() method
+     * \param[in] stream returned by QAbstractGrpcChannel::stream() method
      */
     virtual void cancel(QGrpcStream *stream);
 

+ 20 - 20
src/grpc/qabstractgrpcclient.cpp

@@ -128,20 +128,20 @@ QGrpcAsyncReplyShared QAbstractGrpcClient::call(const QString &method, const QBy
     return reply;
 }
 
-QGrpcStreamShared QAbstractGrpcClient::subscribe(const QString &method, const QByteArray &arg, const QtProtobuf::StreamHandler &handler)
+QGrpcStreamShared QAbstractGrpcClient::stream(const QString &method, const QByteArray &arg, const QtProtobuf::StreamHandler &handler)
 {
-    QGrpcStreamShared stream;
+    QGrpcStreamShared grpcStream;
 
     if (thread() != QThread::currentThread()) {
         QMetaObject::invokeMethod(this, [&]()->QGrpcStreamShared {
                                       qProtoDebug() << "Stream: " << dPtr->service << method << " called from different thread";
-                                      return subscribe(method, arg, handler);
-                                  }, Qt::BlockingQueuedConnection, &stream);
+                                      return stream(method, arg, handler);
+                                  }, Qt::BlockingQueuedConnection, &grpcStream);
     } else if (dPtr->channel) {
-        stream.reset(new QGrpcStream(dPtr->channel, method, arg, handler, this), [](QGrpcStream *stream) { stream->deleteLater(); });
+        grpcStream.reset(new QGrpcStream(dPtr->channel, method, arg, handler, this), [](QGrpcStream *stream) { stream->deleteLater(); });
 
-        auto it = std::find_if(std::begin(dPtr->activeStreams), std::end(dPtr->activeStreams), [stream](const QGrpcStreamShared &activeStream) {
-           return *activeStream == *stream;
+        auto it = std::find_if(std::begin(dPtr->activeStreams), std::end(dPtr->activeStreams), [grpcStream](const QGrpcStreamShared &activeStream) {
+           return *activeStream == *grpcStream;
         });
 
         if (it != std::end(dPtr->activeStreams)) {
@@ -150,15 +150,15 @@ QGrpcStreamShared QAbstractGrpcClient::subscribe(const QString &method, const QB
         }
 
         auto errorConnection = std::make_shared<QMetaObject::Connection>();
-        *errorConnection = connect(stream.get(), &QGrpcStream::error, this, [this, stream](const QGrpcStatus &status) {
-            qProtoWarning() << stream->method() << "call" << dPtr->service << "stream error: " << status.message();
+        *errorConnection = connect(grpcStream.get(), &QGrpcStream::error, this, [this, grpcStream](const QGrpcStatus &status) {
+            qProtoWarning() << grpcStream->method() << "call" << dPtr->service << "stream error: " << status.message();
             error(status);
-            std::weak_ptr<QGrpcStream> weakStream = stream;
+            std::weak_ptr<QGrpcStream> weakStream = grpcStream;
             //TODO: Make timeout configurable from channel settings
-            QTimer::singleShot(1000, this, [this, weakStream, method = stream->method()] {
+            QTimer::singleShot(1000, this, [this, weakStream, method = grpcStream->method()] {
                 auto stream = weakStream.lock();
                 if (stream) {
-                    dPtr->channel->subscribe(stream.get(), dPtr->service, this);
+                    dPtr->channel->stream(stream.get(), dPtr->service, this);
                 } else {
                     qProtoDebug() << "Stream for " << dPtr->service << "method" << method << " will not be restored by timeout.";
                 }
@@ -166,10 +166,10 @@ QGrpcStreamShared QAbstractGrpcClient::subscribe(const QString &method, const QB
         });
 
         auto finishedConnection = std::make_shared<QMetaObject::Connection>();
-        *finishedConnection = connect(stream.get(), &QGrpcStream::finished, this, [this, stream, errorConnection, finishedConnection]() mutable {
-            qProtoWarning() << stream->method() << "call" << dPtr->service << "stream finished";
-            auto it = std::find_if(std::begin(dPtr->activeStreams), std::end(dPtr->activeStreams), [stream](QGrpcStreamShared activeStream) {
-               return *activeStream == *stream;
+        *finishedConnection = connect(grpcStream.get(), &QGrpcStream::finished, this, [this, grpcStream, errorConnection, finishedConnection]() mutable {
+            qProtoWarning() << grpcStream->method() << "call" << dPtr->service << "stream finished";
+            auto it = std::find_if(std::begin(dPtr->activeStreams), std::end(dPtr->activeStreams), [grpcStream](QGrpcStreamShared activeStream) {
+               return *activeStream == *grpcStream;
             });
 
             if (it != std::end(dPtr->activeStreams)) {
@@ -177,15 +177,15 @@ QGrpcStreamShared QAbstractGrpcClient::subscribe(const QString &method, const QB
             }
             QObject::disconnect(*errorConnection);
             QObject::disconnect(*finishedConnection);
-            stream.reset();
+            grpcStream.reset();
         });
 
-        dPtr->channel->subscribe(stream.get(), dPtr->service, this);
-        dPtr->activeStreams.push_back(stream);
+        dPtr->channel->stream(grpcStream.get(), dPtr->service, this);
+        dPtr->activeStreams.push_back(grpcStream);
     } else {
         error({QGrpcStatus::Unknown, QLatin1String("No channel(s) attached.")});
     }
-    return stream;
+    return grpcStream;
 }
 
 QAbstractProtobufSerializer *QAbstractGrpcClient::serializer() const

+ 9 - 9
src/grpc/qabstractgrpcclient.h

@@ -61,7 +61,7 @@ using StreamHandler = std::function<void(const QByteArray&)>;
  * \ingroup QtGrpc
  * \brief The QAbstractGrpcClient class is bridge between gRPC clients and channels. QAbstractGrpcClient provides set of
  *        bridge functions for client classes generated out of protobuf services.
- * \details QAbstractGrpcClient provides threads safety for subscribe and call methods of generated clients.
+ * \details QAbstractGrpcClient provides threads safety for stream and call methods of generated clients.
  */
 class Q_GRPC_EXPORT QAbstractGrpcClient : public QObject
 {
@@ -128,20 +128,20 @@ protected:
 
     /*!
      * \private
-     * \brief Subscribes to message notifications from server-stream with given message argument \a arg
+     * \brief Streams to message notifications from server-stream with given message argument \a arg
      * \param[in] method Name of the method to be called
      * \param[in] arg Protobuf message argument for \p method
      * \param[out] signal Callback with return-message as input parameter that will be called each time message
      *             update recevied from server-stream
      */
     template<typename A>
-    QGrpcStreamShared subscribe(const QString &method, const A &arg) {
-        return subscribe(method, arg.serialize(serializer()));
+    QGrpcStreamShared stream(const QString &method, const A &arg) {
+        return stream(method, arg.serialize(serializer()));
     }
 
     /*!
      * \private
-     * \brief Subscribes to message notifications from server-stream with given message argument \a arg
+     * \brief Streams to message notifications from server-stream with given message argument \a arg
      * \param[in] method Name of the method to be called
      * \param[in] arg Protobuf message argument for \p method
      * \param[out] ret Pointer to preallocated return-message structure. \p ret Structure fields will be update each
@@ -150,15 +150,15 @@ protected:
      *       updated message recevied from server-stream
      */
     template<typename A, typename R>
-    QGrpcStreamShared subscribe(const QString &method, const A &arg, const QPointer<R> &ret) {
+    QGrpcStreamShared stream(const QString &method, const A &arg, const QPointer<R> &ret) {
         if (ret.isNull()) {
-            static const QString nullPointerError("Unable to subscribe method: %1. Pointer to return data is null");
+            static const QString nullPointerError("Unable to stream method: %1. Pointer to return data is null");
             error({QGrpcStatus::InvalidArgument, nullPointerError.arg(method)});
             qProtoCritical() << nullPointerError.arg(method);
             return nullptr;
         }
 
-        return subscribe(method, arg.serialize(serializer()), [ret, this](const QByteArray &data) {
+        return stream(method, arg.serialize(serializer()), [ret, this](const QByteArray &data) {
             if (!ret.isNull()) {
                 tryDeserialize(*ret, data);
             } else {
@@ -190,7 +190,7 @@ private:
     QGrpcAsyncReplyShared call(const QString &method, const QByteArray &arg);
 
     //!\private
-    QGrpcStreamShared subscribe(const QString &method, const QByteArray &arg, const QtProtobuf::StreamHandler &handler = {});
+    QGrpcStreamShared stream(const QString &method, const QByteArray &arg, const QtProtobuf::StreamHandler &handler = {});
 
     /*!
      * \private

+ 4 - 4
src/grpc/qgrpcasyncreply.h

@@ -53,10 +53,10 @@ public:
     void abort();
 
     /*!
-     * \brief Subscribe to QGrpcAsyncReply signals
+     * \brief Stream to QGrpcAsyncReply signals
      */
     template <typename Func1, typename Func2>
-    inline void subscribe(QObject *receiver, Func1 finishCallback, Func2 errorCallback,
+    inline void stream(QObject *receiver, Func1 finishCallback, Func2 errorCallback,
                                      Qt::ConnectionType type = Qt::AutoConnection)
     {
         QObject::connect(this, &QGrpcAsyncReply::finished, receiver, finishCallback, type);
@@ -64,11 +64,11 @@ public:
     }
 
     /*!
-     * \brief Overloaded QGrpcAsyncReply::subscribe method, to subscribe to finished signal
+     * \brief Overloaded QGrpcAsyncReply::stream method, to stream to finished signal
      *        only
      */
     template <typename Func1>
-    inline void subscribe(QObject *receiver, Func1 finishCallback,
+    inline void stream(QObject *receiver, Func1 finishCallback,
                                      Qt::ConnectionType type = Qt::AutoConnection)
     {
         QObject::connect(this, &QGrpcAsyncReply::finished, receiver, finishCallback, type);

+ 4 - 4
src/grpc/qgrpcchannel.cpp

@@ -256,7 +256,7 @@ QGrpcStatus QGrpcChannelPrivate::call(const QString &method, const QString &serv
     return call.status;
 }
 
-void QGrpcChannelPrivate::subscribe(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client)
+void QGrpcChannelPrivate::stream(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client)
 {
     assert(stream != nullptr);
 
@@ -335,9 +335,9 @@ void QGrpcChannel::call(const QString &method, const QString &service, const QBy
     dPtr->call(method, service, args, reply);
 }
 
-void QGrpcChannel::subscribe(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client)
+void QGrpcChannel::stream(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client)
 {
-    dPtr->subscribe(stream, service, client);
+    dPtr->stream(stream, service, client);
 }
 
 std::shared_ptr<QAbstractProtobufSerializer> QGrpcChannel::serializer() const
@@ -346,4 +346,4 @@ std::shared_ptr<QAbstractProtobufSerializer> QGrpcChannel::serializer() const
     return QProtobufSerializerRegistry::instance().getSerializer("protobuf");
 }
 
-}
+}

+ 1 - 1
src/grpc/qgrpcchannel.h

@@ -58,7 +58,7 @@ public:
 
     QGrpcStatus call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret) override;
     void call(const QString &method, const QString &service, const QByteArray &args, QtProtobuf::QGrpcAsyncReply *reply) override;
-    void subscribe(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client) override;
+    void stream(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client) override;
     std::shared_ptr<QAbstractProtobufSerializer> serializer() const override;
 
 private:

+ 1 - 1
src/grpc/qgrpcchannel_p.h

@@ -101,7 +101,7 @@ struct QGrpcChannelPrivate {
 
     void call(const QString &method, const QString &service, const QByteArray &args, QGrpcAsyncReply *reply);
     QGrpcStatus call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret);
-    void subscribe(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client);
+    void stream(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client);
 };
 
 };

+ 11 - 11
src/grpc/qgrpchttp2channel.cpp

@@ -269,15 +269,15 @@ void QGrpcHttp2Channel::call(const QString &method, const QString &service, cons
     });
 }
 
-void QGrpcHttp2Channel::subscribe(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client)
+void QGrpcHttp2Channel::stream(QGrpcStream *grpcStream, const QString &service, QAbstractGrpcClient *client)
 {
-    assert(stream != nullptr);
-    QNetworkReply *networkReply = dPtr->post(stream->method(), service, stream->arg(), true);
+    assert(grpcStream != nullptr);
+    QNetworkReply *networkReply = dPtr->post(grpcStream->method(), service, grpcStream->arg(), true);
 
     std::shared_ptr<QMetaObject::Connection> finishConnection(new QMetaObject::Connection);
     std::shared_ptr<QMetaObject::Connection> abortConnection(new QMetaObject::Connection);
     std::shared_ptr<QMetaObject::Connection> readConnection(new QMetaObject::Connection);
-    *readConnection = QObject::connect(networkReply, &QNetworkReply::readyRead, stream, [networkReply, stream, this]() {
+    *readConnection = QObject::connect(networkReply, &QNetworkReply::readyRead, grpcStream, [networkReply, grpcStream, this]() {
         auto replyIt = dPtr->activeStreamReplies.find(networkReply);
 
         QByteArray data = networkReply->readAll();
@@ -289,7 +289,7 @@ void QGrpcHttp2Channel::subscribe(QGrpcStream *stream, const QString &service, Q
             qProtoDebug() << "First chunk received: " << data.size() << " expectedDataSize: " << expectedDataSize;
 
             if (expectedDataSize == 0) {
-                stream->handler(QByteArray());
+                grpcStream->handler(QByteArray());
                 return;
             }
 
@@ -303,7 +303,7 @@ void QGrpcHttp2Channel::subscribe(QGrpcStream *stream, const QString &service, Q
         qProtoDebug() << "Proceed chunk: " << data.size() << " dataContainer: " << dataContainer.container.size() << " capacity: " << dataContainer.expectedSize;
         while (dataContainer.container.size() >= dataContainer.expectedSize && !networkReply->isFinished()) {
             qProtoDebug() << "Full data received: " << data.size() << " dataContainer: " << dataContainer.container.size() << " capacity: " << dataContainer.expectedSize;
-            stream->handler(dataContainer.container.mid(GrpcMessageSizeHeaderSize, dataContainer.expectedSize - GrpcMessageSizeHeaderSize));
+            grpcStream->handler(dataContainer.container.mid(GrpcMessageSizeHeaderSize, dataContainer.expectedSize - GrpcMessageSizeHeaderSize));
             dataContainer.container.remove(0, dataContainer.expectedSize);
             if (dataContainer.container.size() > GrpcMessageSizeHeaderSize) {
                 dataContainer.expectedSize = QGrpcHttp2ChannelPrivate::getExpectedDataSize(dataContainer.container);
@@ -332,7 +332,7 @@ void QGrpcHttp2Channel::subscribe(QGrpcStream *stream, const QString &service, Q
         networkReply->deleteLater();
     });
 
-    *finishConnection = QObject::connect(networkReply, &QNetworkReply::finished, stream, [stream, service, networkReply, abortConnection, readConnection, finishConnection, client, this]() {
+    *finishConnection = QObject::connect(networkReply, &QNetworkReply::finished, grpcStream, [grpcStream, service, networkReply, abortConnection, readConnection, finishConnection, client, this]() {
         QString errorString = networkReply->errorString();
         QNetworkReply::NetworkError networkError = networkReply->error();
         if (*readConnection) {
@@ -345,22 +345,22 @@ void QGrpcHttp2Channel::subscribe(QGrpcStream *stream, const QString &service, Q
         dPtr->activeStreamReplies.erase(networkReply);
         QGrpcHttp2ChannelPrivate::abortNetworkReply(networkReply);
         networkReply->deleteLater();
-        qProtoWarning() << stream->method() << "call" << service << "stream finished: " << errorString;
+        qProtoWarning() << grpcStream->method() << "call" << service << "stream finished: " << errorString;
         switch (networkError) {
         case QNetworkReply::RemoteHostClosedError:
             qProtoDebug() << "Remote server closed connection. Reconnect silently";
-            subscribe(stream, service, client);
+            stream(grpcStream, service, client);
             break;
         case QNetworkReply::NoError:
             //Reply closed without error
             break;
         default:
-            stream->error(QGrpcStatus{StatusCodeMap.at(networkError), QString("%1 call %2 stream failed: %3").arg(service).arg(stream->method()).arg(errorString)});
+            grpcStream->error(QGrpcStatus{StatusCodeMap.at(networkError), QString("%1 call %2 stream failed: %3").arg(service).arg(grpcStream->method()).arg(errorString)});
             break;
         }
     });
 
-    *abortConnection = QObject::connect(stream, &QGrpcStream::finished, networkReply, [networkReply, finishConnection, abortConnection, readConnection] {
+    *abortConnection = QObject::connect(grpcStream, &QGrpcStream::finished, networkReply, [networkReply, finishConnection, abortConnection, readConnection] {
         if (*finishConnection) {
             QObject::disconnect(*finishConnection);
         }

+ 1 - 1
src/grpc/qgrpchttp2channel.h

@@ -57,7 +57,7 @@ public:
 
     QGrpcStatus call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret) override;
     void call(const QString &method, const QString &service, const QByteArray &args, QtProtobuf::QGrpcAsyncReply *reply) override;
-    void subscribe(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client) override;
+    void stream(QGrpcStream *stream, const QString &service, QAbstractGrpcClient *client) override;
     std::shared_ptr<QAbstractProtobufSerializer> serializer() const override;
 private:
     Q_DISABLE_COPY_MOVE(QGrpcHttp2Channel)

+ 3 - 3
src/grpc/quick/qquickgrpcstream.cpp

@@ -64,19 +64,19 @@ void QQuickGrpcStream::updateStream()
         return;
     }
 
-    if (!subscribe()) {
+    if (!stream()) {
         setEnabled(false);
     }
 }
 
-bool QQuickGrpcStream::subscribe()
+bool QQuickGrpcStream::stream()
 {
     QString uppercaseMethodName = m_method;
     uppercaseMethodName.replace(0, 1, m_method[0].toUpper());
     const QMetaObject *metaObject = m_client->metaObject();
     QMetaMethod method;
     for (int i = 0; i < metaObject->methodCount(); i++) {
-        if (QString("qmlSubscribe%1_p").arg(uppercaseMethodName) == metaObject->method(i).name()) {
+        if (QString("qmlStream%1_p").arg(uppercaseMethodName) == metaObject->method(i).name()) {
             method = metaObject->method(i);
             break;
         }

+ 2 - 2
src/grpc/quick/qquickgrpcstream_p.h

@@ -35,7 +35,7 @@
  * \brief GrpcStream provides access to gRPC streams from QML.
  *
  * \details GrpcStream might be used from QML code to receive updates for gRPC server or bidirectional streaming methods.
- * Follwing properties should be provided and can not be empty, to subscribe streaming method:
+ * Follwing properties should be provided and can not be empty, to stream streaming method:
  * - client
  * - method
  * - argument
@@ -178,7 +178,7 @@ signals:
 
 private:
     void updateStream();
-    bool subscribe();
+    bool stream();
     QPointer<QAbstractGrpcClient> m_client;
     bool m_enabled;
     QString m_method;

+ 17 - 17
tests/test_grpc/clienttest.cpp

@@ -237,7 +237,7 @@ TEST_P(ClientTest, StringEchoStreamTest)
     QEventLoop waiter;
 
     int i = 0;
-    auto stream = testClient->subscribeTestMethodServerStream(request);
+    auto stream = testClient->streamTestMethodServerStream(request);
     QObject::connect(stream.get(), &QGrpcStream::messageReceived, &m_app, [&result, &i, &waiter, stream]() {
         SimpleStringMessage ret = stream->read<SimpleStringMessage>();
 
@@ -269,7 +269,7 @@ TEST_P(ClientTest, StringEchoStreamAbortTest)
     QEventLoop waiter;
 
     int i = 0;
-    auto stream = testClient->subscribeTestMethodServerStream(request);
+    auto stream = testClient->streamTestMethodServerStream(request);
     QObject::connect(stream.get(), &QGrpcStream::messageReceived, &m_app, [&result, &i, &waiter, stream]() {
         SimpleStringMessage ret = stream->read<SimpleStringMessage>();
         ++i;
@@ -301,7 +301,7 @@ TEST_P(ClientTest, StringEchoStreamAbortByTimerTest)
 
 
     int i = 0;
-    auto stream = testClient->subscribeTestMethodServerStream(request);
+    auto stream = testClient->streamTestMethodServerStream(request);
     QTimer::singleShot(3500, stream.get(), [stream]() {
         stream->cancel();
     });
@@ -343,7 +343,7 @@ TEST_P(ClientTest, StringEchoStreamTestRet)
 
     QEventLoop waiter;
 
-    testClient->subscribeTestMethodServerStream(request, result);
+    testClient->streamTestMethodServerStream(request, result);
 
     int i = 0;
     QObject::connect(result.data(), &SimpleStringMessage::testFieldStringChanged, &m_app, [&i]() {
@@ -372,7 +372,7 @@ TEST_P(ClientTest, HugeBlobEchoStreamTest)
     QByteArray dataHash = QCryptographicHash::hash(request.testBytes(), QCryptographicHash::Sha256);
     QEventLoop waiter;
 
-    auto stream = testClient->subscribeTestMethodBlobServerStream(request);
+    auto stream = testClient->streamTestMethodBlobServerStream(request);
 
     QObject::connect(stream.get(), &QGrpcStream::messageReceived, &m_app, [&result, &waiter, stream]() {
         BlobMessage ret = stream->read<BlobMessage>();
@@ -510,7 +510,7 @@ TEST_F(ClientTest, ClientSyncTestUnattachedChannelSignal)
     delete ret;
 }
 
-TEST_P(ClientTest, AsyncReplySubscribeTest)
+TEST_P(ClientTest, AsyncReplyStreamTest)
 {
     auto testClient = (*GetParam())();
     QTimer callTimeout;
@@ -523,7 +523,7 @@ TEST_P(ClientTest, AsyncReplySubscribeTest)
     callTimeout.setInterval(5000);
     auto reply = testClient->testMethodStatusMessage(request);
 
-    reply->subscribe(&m_app, []() {
+    reply->stream(&m_app, []() {
         ASSERT_TRUE(false);
     },
     [&asyncStatus, &waiter, &statusMessage](const QGrpcStatus &status) {
@@ -542,7 +542,7 @@ TEST_P(ClientTest, AsyncReplySubscribeTest)
     request.setTestFieldString("Hello beach!");
 
     reply = testClient->testMethod(request);
-    reply->subscribe(&m_app, [reply, &result, &waiter]() {
+    reply->stream(&m_app, [reply, &result, &waiter]() {
         result = reply->read<SimpleStringMessage>();
         waiter.quit();
     });
@@ -556,7 +556,7 @@ TEST_P(ClientTest, AsyncReplySubscribeTest)
     request.setTestFieldString("Hello beach1!");
 
     reply = testClient->testMethod(request);
-    reply->subscribe(&m_app, [reply, &result, &waiter]() {
+    reply->stream(&m_app, [reply, &result, &waiter]() {
         result = reply->read<SimpleStringMessage>();
         waiter.quit();
     }, []() {
@@ -578,8 +578,8 @@ TEST_P(ClientTest, MultipleStreamsTest)
     QEventLoop waiter;
     request.setTestFieldString("Stream");
 
-    auto stream = testClient->subscribeTestMethodServerStream(request);
-    auto streamNext = testClient->subscribeTestMethodServerStream(request);
+    auto stream = testClient->streamTestMethodServerStream(request);
+    auto streamNext = testClient->streamTestMethodServerStream(request);
 
     ASSERT_EQ(stream, streamNext);
 
@@ -606,8 +606,8 @@ TEST_P(ClientTest, MultipleStreamsCancelTest)
     SimpleStringMessage request;
     request.setTestFieldString("Stream");
 
-    auto stream = testClient->subscribeTestMethodServerStream(request);
-    auto streamNext = testClient->subscribeTestMethodServerStream(request);
+    auto stream = testClient->streamTestMethodServerStream(request);
+    auto streamNext = testClient->streamTestMethodServerStream(request);
 
     ASSERT_EQ(stream, streamNext);
 
@@ -626,10 +626,10 @@ TEST_P(ClientTest, MultipleStreamsCancelTest)
     ASSERT_TRUE(isFinished);
     ASSERT_TRUE(isFinishedNext);
 
-    stream = testClient->subscribeTestMethodServerStream(request);
+    stream = testClient->streamTestMethodServerStream(request);
     ASSERT_NE(stream, streamNext);
 
-    streamNext = testClient->subscribeTestMethodServerStream(request);
+    streamNext = testClient->streamTestMethodServerStream(request);
 
     ASSERT_EQ(stream, streamNext);
 
@@ -744,7 +744,7 @@ TEST_P(ClientTest, StringEchoStreamThreadTest)
     std::shared_ptr<QThread> thread(QThread::create([&](){
         QEventLoop waiter;
         QThread *validThread = QThread::currentThread();
-        auto stream = testClient->subscribeTestMethodServerStream(request);
+        auto stream = testClient->streamTestMethodServerStream(request);
         QObject::connect(stream.get(), &QGrpcStream::messageReceived, &waiter, [&result, &i, &waiter, stream, &threadsOk, validThread]() {
             SimpleStringMessage ret = stream->read<SimpleStringMessage>();
             result.setTestFieldString(result.testFieldString() + ret.testFieldString());
@@ -796,7 +796,7 @@ TEST_P(ClientTest, StreamCancelWhileErrorTimeoutTest)
     QEventLoop waiter;
 
     bool ok = false;
-    auto stream = testClient->subscribeTestMethodServerStream(request);
+    auto stream = testClient->streamTestMethodServerStream(request);
     QObject::connect(stream.get(), &QGrpcStream::finished, &m_app, [&ok, &waiter]() {
         ok = true;
         waiter.quit();