QAbstractGrpcClient Class | Qt GRPC 6.6.2
Description: The QAbstractGrpcClient class is bridge between gRPC clients and channels.

- Qt 6.6
- Qt GRPC
- C++ Classes
- QtGrpc (Technical Preview)
- QAbstractGrpcClient
- Qt 6.6.2 Reference Documentation

# QAbstractGrpcClient Class

The QAbstractGrpcClient class is bridge between gRPC clients and channels. More...

Header: | #include <QAbstractGrpcClient>
CMake: | find_package(Qt6 REQUIRED COMPONENTS Grpc) target_link_libraries(mytarget PRIVATE Qt6::Grpc)
Since: | Qt 6.5
Inherits: | QObject
Status: | Technical Preview

- List of all members, including inherited members

## Public Functions

void | attachChannel(const std::shared_ptr<QAbstractGrpcChannel> &channel)

## Protected Functions

QGrpcStatus | call(QLatin1StringView method, const QProtobufMessage &arg, ReturnType &ret, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcCallReply> | call(QLatin1StringView method, const QProtobufMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcStream> | startStream(QLatin1StringView method, const QProtobufMessage &arg, const QGrpcCallOptions &options)

## Detailed Description

QAbstractGrpcClient provides a set of functions for client classes generated out of protobuf services. QAbstractGrpcClient enforces thread safety for startStream() and call() methods of generated clients. The methods QAbstractGrpcClient::call() and QAbstractGrpcClient::startStream() should only be called by the generated client classes.

## Member Function Documentation

### void QAbstractGrpcClient::attachChannel(const std::shared_ptr<QAbstractGrpcChannel> &channel)

Attaches channel to client as transport layer for gRPC.

Parameters and return values will be serialized to the channel in a format it supports.

Note: Warning: Qt GRPC doesn't guarantee thread safety on the channel level. You have to invoke the channel-related functions on the same thread as QAbstractGrpcClient.

### `[protected]` template <typename ParamType, typename ReturnType> QGrpcStatus QAbstractGrpcClient::call(QLatin1StringView method, const QProtobufMessage &arg, ReturnType &ret, const QGrpcCallOptions &options)

Synchronously calls the given method of this service client, with argument arg and fills ret with gRPC reply. Uses options argument to set additional parameter for the call.

### `[protected]` template <typename ParamType> std::shared_ptr<QGrpcCallReply> QAbstractGrpcClient::call(QLatin1StringView method, const QProtobufMessage &arg, const QGrpcCallOptions &options)

Synchronously calls the given method of this service client, with argument arg. Uses options argument to set additional parameter for the call.

### `[protected]` template <typename ParamType> std::shared_ptr<QGrpcStream> QAbstractGrpcClient::startStream(QLatin1StringView method, const QProtobufMessage &arg, const QGrpcCallOptions &options)

Streams messages from the server stream method with the message argument arg to the attached channel. Uses options argument to set additional parameter for the call.