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
이 열거형 유형은 구독이 가질 수 있는 상태를 나타냅니다.
| 상수 | 값 | 설명 |
|---|---|---|
QMqttSubscription::Unsubscribed | 0 | 해당 토픽에 대한 구독이 해지되었습니다. |
QMqttSubscription::SubscriptionPending | 1 | 구독 요청이 전송되었으나, 브로커에서 아직 확인되지 않았습니다. |
QMqttSubscription::Subscribed | 2 | 구독이 성공적으로 완료되어 메시지를 수신하게 됩니다. |
QMqttSubscription::UnsubscriptionPending | 3 | 토픽 구독 취소 요청이 전송되었으나, 브로커에서 아직 확인되지 않았습니다. |
QMqttSubscription::Error | 4 | 오류가 발생했습니다. |
속성 문서
[read-only] qos : quint8
이 속성은 구독이 설정된 QoS 수준을 나타냅니다.
구독의 QoS 수준은 클라이언트가 메시지를 수신할 수 있는 최대 QoS 수준을 지정합니다. 게시자는 여전히 더 낮은 수준의 메시지를 보낼 수 있습니다.
액세스 함수:
| quint8 | qos() const |
알림 신호:
| void | qosChanged(quint8) |
[read-only] reason : QString
이 속성은 구독에 대한 사유 문자열을 포함합니다.
사유 문자열은 서버가 구독에 대한 추가 정보를 제공하기 위해 사용됩니다. 서버가 이를 전송할지 여부는 선택 사항입니다.
액세스 함수:
| QString | reason() const |
[read-only] reasonCode : QMqtt::ReasonCode
이 속성은 구독에 대한 오류 코드를 포함합니다.
이유 코드는 구독이 실패한 경우 오류 유형을, 성공한 경우 QoS 수준을 나타냅니다.
액세스 함수:
| QMqtt::ReasonCode | reasonCode() const |
[read-only] sharedSubscription : bool
이 속성은 구독이 공유되는지 여부를 나타냅니다.
액세스 함수:
| bool | isSharedSubscription() const |
[read-only] sharedSubscriptionName : QString
이 속성은 공유 구독의 이름을 저장합니다.
액세스 함수:
| QString | sharedSubscriptionName() const |
[read-only] state : SubscriptionState
이 속성은 구독의 상태를 저장합니다.
액세스 함수:
| QMqttSubscription::SubscriptionState | state() const |
알림 신호:
| void | stateChanged(QMqttSubscription::SubscriptionState state) |
[read-only] topic : 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::ProtocolVersion`에 ` QMqttClient::MQTT_5_0 `을 지정했을 때만 유효한 데이터를 제공합니다.
© 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.