QGrpcHttp2Channel Class

QGrpcHttp2Channel 클래스는 통신을 위한 HTTP/2 전송 계층을 제공합니다. gRPC 통신을 위한 HTTP/2 전송 계층을 제공합니다. 더 보기...

헤더: #include <QGrpcHttp2Channel>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
이후 Qt 6.5
QML에서: GrpcHttp2Channel
상속합니다: QAbstractGrpcChannel

공용 함수

QGrpcHttp2Channel(const QUrl &hostUri)
QGrpcHttp2Channel(const QUrl &hostUri, const QGrpcChannelOptions &options)
virtual ~QGrpcHttp2Channel() override
QUrl hostUri() const

상세 설명

QGrpcHttp2Channel 클래스는 QAbstractGrpcChannel 를 구현합니다. gRPC 통신을 가능하게 합니다.

HTTP/2는 이전 버전인 HTTP/1.1에 비해 몇 가지 장점을 도입하여 다중화된 TCP 연결을 사용하여 보안이나 안정성을 희생하지 않으면서 효율적인 통신이 필요한 고성능 실시간 애플리케이션에 QGrpcHttp2Channel이 적합합니다.

이 채널은 SSL 지원, 사용자 지정 serializationFormat 또는 필요한 사용자 지정이 포함된 QGrpcChannelOptions 으로 구성하여 다른 옵션으로 사용자 지정할 수 있습니다.

콘텐츠 유형

gRPC over HTTP/2의 콘텐츠 유형에 따라 메시지 직렬화 형식이 결정됩니다. application/grpc 로 시작해야 하며 접미사를 포함할 수 있습니다. 형식은 이 체계를 따릅니다:

"content-type": "application/grpc" [("+proto" / "+json" / {custom})]

예를 들어

  • application/grpc+proto 는 Protobuf 인코딩을 지정합니다.
  • application/grpc+json 는 JSON 인코딩을 지정합니다.

직렬화 형식은 메타데이터 내에 content-type 을 지정하거나 serializationFormat 을 직접 설정하여 구성할 수 있습니다. 기본적으로 application/grpc 콘텐츠 유형이 사용됩니다.

content-type 메타데이터를 사용하여 JSON 직렬화 형식으로 QGrpcHttp2Channel을 구성하려면 다음과 같이 하세요:

auto jsonChannel = std::make_shared<QGrpcHttp2Channel>(
    QUrl("http://localhost:50051"_L1),
    QGrpcChannelOptions().setMetadata({
        { "content-type"_ba, "application/grpc+json"_ba },
    })
);

사용자 정의 직렬화기 및 content-type 의 경우 직렬화 형식을 직접 설정할 수 있습니다:

class DummySerializer : public QAbstractProtobufSerializer
{
    ...
};
QGrpcSerializationFormat dummyFormat("dummy", std::make_shared<DummySerializer>());
auto dummyChannel = std::make_shared<QGrpcHttp2Channel>(
    QUrl("http://localhost:50051"_L1),
    QGrpcChannelOptions().setSerializationFormat(dummyFormat)
);

dummy 접미사가 있는 메시지를 인코딩 및 디코딩할 때 DummySerializer 을 사용합니다. HTTP/2 전송의 경우 application/grpc+dummy 콘텐츠 유형이 됩니다.

참고: 사용자 정의 직렬화기를 사용하려면 지정된 형식에 대한 서버 지원이 필요합니다.

QAbstractGrpcChannel, QGrpcChannelOptions, QGrpcSerializationFormat참조하세요 .

멤버 함수 문서

[explicit] QGrpcHttp2Channel::QGrpcHttp2Channel(const QUrl &hostUri)

hostUri 를 사용하여 QGrpcHttp2Channel을 구축합니다.

[explicit] QGrpcHttp2Channel::QGrpcHttp2Channel(const QUrl &hostUri, const QGrpcChannelOptions &options)

hostUrioptions 로 QGrpcHttp2Channel 을 구축합니다.

[override virtual noexcept] QGrpcHttp2Channel::~QGrpcHttp2Channel()

QGrpcHttp2Channel 객체를 삭제합니다.

QUrl QGrpcHttp2Channel::hostUri() const

이 채널의 호스트 URI를 반환합니다.

© 2025 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.