QMqttSubscription Class
QMqttSubscription 클래스는 지정된 주제에 대한 MQTT 브로커의 알림을 받습니다. 더 보기...
헤더: | #include <QMqttSubscription> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Mqtt) target_link_libraries(mytarget PRIVATE Qt6::Mqtt) |
qmake: | QT += mqtt |
상속합니다: | QObject |
공용 유형
enum | SubscriptionState { Unsubscribed, SubscriptionPending, Subscribed, UnsubscriptionPending, Error } |
속성
|
|
공용 기능
virtual | ~QMqttSubscription() override |
bool | isSharedSubscription() const |
quint8 | qos() const |
QString | reason() const |
QMqtt::ReasonCode | reasonCode() const |
QString | sharedSubscriptionName() const |
QMqttSubscription::SubscriptionState | state() const |
QMqttTopicFilter | topic() const |
QMqttUserProperties | userProperties() const |
공용 슬롯
void | unsubscribe() |
신호
void | messageReceived(QMqttMessage msg) |
void | qosChanged(quint8) |
void | stateChanged(QMqttSubscription::SubscriptionState state) |
멤버 유형 문서
enum QMqttSubscription::SubscriptionState
이 열거형 유형은 구독이 가질 수 있는 상태를 설명합니다.
Constant | 값 | 설명 |
---|---|---|
QMqttSubscription::Unsubscribed | 0 | 토픽의 구독이 취소되었습니다. |
QMqttSubscription::SubscriptionPending | 1 | 구독 요청이 전송되었지만 브로커가 아직 확인하지 않은 상태입니다. |
QMqttSubscription::Subscribed | 2 | 구독이 성공했으며 메시지가 수신됩니다. |
QMqttSubscription::UnsubscriptionPending | 3 | 토픽의 구독 취소 요청이 전송되었지만 브로커에서 아직 확인하지 않았습니다. |
QMqttSubscription::Error | 4 | 오류가 발생했습니다. |
부동산 문서
[read-only]
qos : const quint8
이 속성에는 가입이 이루어진 QoS 수준이 저장됩니다.
구독의 QoS 수준은 클라이언트가 메시지를 수신할 수 있는 최대 QoS 수준을 지정합니다. 게시자는 여전히 더 낮은 수준에서 메시지를 보낼 수 있습니다.
액세스 기능:
quint8 | qos() const |
알림 신호:
void | qosChanged(quint8) |
[read-only]
reason : const QString
이 속성에는 구독의 이유 문자열이 저장됩니다.
이유 문자열은 서버에서 구독에 대한 추가 정보를 제공하는 데 사용됩니다. 서버에서 이 문자열을 전송하는 것은 선택 사항입니다.
액세스 함수:
QString | reason() const |
[read-only]
reasonCode : const QMqtt::ReasonCode
이 속성에는 구독의 이유 코드가 저장됩니다.
이유 코드는 구독이 실패한 경우 오류 유형을 지정하고, 성공한 경우 QoS 수준을 지정합니다.
액세스 기능:
QMqtt::ReasonCode | reasonCode() const |
[read-only]
sharedSubscription : const bool
이 속성에는 구독이 공유되는지 여부가 저장됩니다.
액세스 기능:
bool | isSharedSubscription() const |
[read-only]
sharedSubscriptionName : const QString
이 속성에는 공유 구독의 이름이 저장됩니다.
액세스 함수:
QString | sharedSubscriptionName() const |
[read-only]
state : const SubscriptionState
이 속성에는 구독의 상태가 저장됩니다.
액세스 함수:
QMqttSubscription::SubscriptionState | state() const |
알림 신호:
void | stateChanged(QMqttSubscription::SubscriptionState state) |
[read-only]
topic : const QMqttTopicFilter
이 속성에는 구독의 주제가 저장됩니다.
액세스 함수입니다:
QMqttTopicFilter | topic() const |
멤버 함수 문서
[override virtual noexcept]
QMqttSubscription::~QMqttSubscription()
구독을 삭제합니다. topic 에서 아직 구독을 취소하지 않은 경우 자동으로 구독이 취소됩니다.
[signal]
void QMqttSubscription::messageReceived(QMqttMessage msg)
이 신호는 새 메시지 msg 가 수신되면 발신됩니다.
[slot]
void QMqttSubscription::unsubscribe()
topic 에서 구독을 취소합니다.
참고: QMqttClient::subscribe()에서 반환하는 모든 공유 포인터 인스턴스에 영향을 줄 수 있습니다.
QMqttUserProperties QMqttSubscription::userProperties() const
구독이 수락되었을 때 브로커로부터 받은 사용자 속성을 반환합니다.
참고: 이 함수는 클라이언트가 QMqttClient::MQTT_5_0 을 QMqttClient::ProtocolVersion 으로 지정한 경우에만 유효한 데이터를 제공합니다.
© 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.