QAbstractGrpcClient Class

The QAbstractGrpcClient class is bridge between gRPC clients and channels. 更多...

头: #include <QAbstractGrpcClient>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
Since: Qt 6.5
继承: QObject
状态: 技术预览

公共函数

void attachChannel (const std::shared_ptr<QAbstractGrpcChannel> & channel )
(从 6.7 起) const std::shared_ptr<QAbstractGrpcChannel> & channel ()

信号

(从 6.7 起) void channelChanged ()
void errorOccurred (const QGrpcStatus & status )

保护函数

std::shared_ptr<StreamType> startStream (QLatin1StringView method , const QProtobufMessage & arg , const QGrpcCallOptions & options )

详细描述

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.

成员函数文档编制

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.

注意: 警告 : 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 .

注意: setter 函数对于特性 channel .

[since 6.7] const std::shared_ptr < QAbstractGrpcChannel > &QAbstractGrpcClient:: channel ()

Returns the channel attached to this client.

注意: Getter function for property channel.

该函数在 Qt 6.7 引入。

[signal, since 6.7] void QAbstractGrpcClient:: channelChanged ()

Indicates that a new channel is attached to the client.

注意: 通知程序信号对于特性 channel .

该函数在 Qt 6.7 引入。

[signal] void QAbstractGrpcClient:: errorOccurred (const QGrpcStatus & status )

Indicates that an error occurred during serialization.

This signal is emitted when an error with status occurs in the channel or during serialization.

另请参阅 QGrpcOperation::errorOccurred .

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

Starts the stream method StreamType type with the message argument arg to the attached channel.

Uses options argument to set additional parameter in the stream communication.

The implementation is only available for StreamType : QGrpcServerStream , QGrpcClientStream ,和 QGrpcBidirStream .