本页内容

QGrpcMessageReceivedInterceptor Class

拦截 RPC 的传入消息有效载荷。更多...

头文件: #include <QGrpcInterceptor>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
自: Qt 6.11

注意:该类中的所有函数均为可重入函数。

公共函数

virtual ~QGrpcMessageReceivedInterceptor()
virtual void onMessageReceived(QGrpcInterceptionContext &context, QByteArray &messageData) = 0

详细说明

实现 QGrpcMessageReceivedInterceptor 以监视或修改从 RPC 接收的消息的序列化消息负载。

有关拦截机制的介绍以及拦截器接口如何参与 RPC 生命周期的信息,请参阅《Qt GRPC 拦截器概述》。

注意:此 拦截器在出站方向上运行。有关多个拦截器回调如何流经链的详细信息,请参阅“方向和流”部分。

另请参阅 QtGrpc::InterceptorCapability::MessageReceived 和QGrpcInterceptionContext 。

成员函数文档

[virtual noexcept] QGrpcMessageReceivedInterceptor::~QGrpcMessageReceivedInterceptor()

摧毁了这架拦截机。

[pure virtual] void QGrpcMessageReceivedInterceptor::onMessageReceived(QGrpcInterceptionContext &context, QByteArray &messageData)

当收到新消息有效载荷messageData 时调用。

context 提供了有关被拦截的 RPC 的信息。messageData 包含序列化的消息字节,并且可以就地修改。

另请参阅 QGrpcServerStream::messageReceived() 和QGrpcBidiStream::messageReceived()。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.