이 페이지에서

QCoapMessage Class

QCoapMessage 클래스는 요청 또는 응답이 될 수 있는 CoAP 메시지에 대한 정보를 담고 있습니다. 더 보기...

헤더: #include <QCoapMessage>
CMake: find_package(Qt6 REQUIRED COMPONENTS Coap)
target_link_libraries(mytarget PRIVATE Qt6::Coap)
qmake: QT += coap
상속된 항목:

QCoapRequest

참고: 이 클래스의 모든 함수는 재진입 가능합니다.

공개 유형

enum class Type { Confirmable, NonConfirmable, Acknowledgment, Reset }

공개 함수

QCoapMessage()
QCoapMessage(const QCoapMessage &other)
~QCoapMessage()
void addOption(const QCoapOption &option)
void addOption(QCoapOption::OptionName name, const QByteArray &value = QByteArray())
void clearOptions()
bool hasOption(QCoapOption::OptionName name) const
quint16 messageId() const
QCoapOption option(QCoapOption::OptionName name) const
QCoapOption optionAt(int index) const
int optionCount() const
const QList<QCoapOption> &options() const
QList<QCoapOption> options(QCoapOption::OptionName name) const
QByteArray payload() const
void removeOption(QCoapOption::OptionName name)
void removeOption(const QCoapOption &option)
void setMessageId(quint16 id)
void setOptions(const QList<QCoapOption> &options)
void setPayload(const QByteArray &payload)
void setToken(const QByteArray &token)
void setType(const QCoapMessage::Type &type)
void setVersion(quint8 version)
void swap(QCoapMessage &other)
QByteArray token() const
quint8 tokenLength() const
QCoapMessage::Type type() const
quint8 version() const
QCoapMessage &operator=(QCoapMessage &&other)
QCoapMessage &operator=(const QCoapMessage &other)

상세 설명

메시지 유형, 메시지 ID, 토큰 및 기타 보조 데이터와 같은 정보를 포함합니다.

QCoapOption, QCoapReply 및 QCoapRequest도 참조하십시오 .

멤버 유형 설명

enum class QCoapMessage::Type

메시지의 유형을 나타냅니다.

상수값설명
QCoapMessage::Type::Confirmable0확인 가능한 메시지입니다. 수신 엔드포인트는 메시지에 대한 확인 응답을 보내야 합니다.
QCoapMessage::Type::NonConfirmable1확인 불가능한 메시지입니다. 대상 엔드포인트는 메시지에 대해 확인 응답을 보낼 필요가 없습니다.
QCoapMessage::Type::Acknowledgment2확인 메시지. 확인 가능한 메시지에 대한 응답으로 전송되거나 수신되는 메시지입니다.
QCoapMessage::Type::Reset3재설정 메시지. 이 메시지 유형은 오류 발생 시 또는 진행 중인 전송을 중지할 때 사용됩니다. (예를 들어, 관측을 취소하는 데 사용됩니다.)

멤버 함수 설명서

QCoapMessage::QCoapMessage()

새로운 QCoapMessage 객체를 생성합니다.

QCoapMessage::QCoapMessage(const QCoapMessage &other)

other 의 얕은 복사본을 생성합니다.

[noexcept] QCoapMessage::~QCoapMessage()

QCoapMessage 를 삭제합니다.

void QCoapMessage::addOption(const QCoapOption &option)

지정된 CoAP option 를 추가합니다.

void QCoapMessage::addOption(QCoapOption::OptionName name, const QByteArray &value = QByteArray())

지정된 name 및 value 를 사용하여 CoAP 옵션을 추가합니다.

이 함수는 오버로드된 함수입니다.

void QCoapMessage::clearOptions()

모든 옵션을 제거합니다.

bool QCoapMessage::hasOption(QCoapOption::OptionName name) const

메시지에 ` name`가 포함된 옵션이 하나 이상 있으면 ` true `를 반환합니다.

quint16 QCoapMessage::messageId() const

메시지 ID를 반환합니다.

setMessageId()도 참조하십시오 .

QCoapOption QCoapMessage::option(QCoapOption::OptionName name) const

지정된 ` name`을 가진 첫 번째 옵션을 찾아 반환합니다. 해당 옵션이 없는 경우, 값이 비어 있는 유효하지 않은 ` QCoapOption `을 반환합니다.

QCoapOption QCoapMessage::optionAt(int index) const

index 위치에 있는 옵션을 반환합니다.

int QCoapMessage::optionCount() const

옵션의 개수를 반환합니다.

const QList<QCoapOption> &QCoapMessage::options() const

옵션 목록을 반환합니다.

setOptions()도 참조하십시오 .

QList<QCoapOption> QCoapMessage::options(QCoapOption::OptionName name) const

지정된 ` name`를 가진 옵션 목록을 찾아 반환합니다.

QByteArray QCoapMessage::payload() const

페이로드를 반환합니다.

setPayload()도 참조하십시오 .

void QCoapMessage::removeOption(QCoapOption::OptionName name)

지정된 name 를 가진 모든 옵션을 제거합니다. CoAP 프로토콜에서는 동일한 옵션이 중복될 수 있습니다.

void QCoapMessage::removeOption(const QCoapOption &option)

지정된 option 를 제거합니다.

void QCoapMessage::setMessageId(quint16 id)

메시지 ID를 id 로 설정합니다.

messageId()도 참조하십시오 .

void QCoapMessage::setOptions(const QList<QCoapOption> &options)

메시지 옵션을 options 로 설정합니다.

options()도 참조하십시오 .

void QCoapMessage::setPayload(const QByteArray &payload)

메시지 페이로드를 payload 로 설정합니다. 페이로드는 CoAP 콘텐츠 형식 레지스트리에 정의된 콘텐츠 형식 중 하나로 표현될 수 있습니다.

참고: CoAP는 XML, JSON 등과 같은 일반적인 콘텐츠 형식을 지원하지만, 이러한 형식은 텍스트 기반이므로 페이로드 크기가 크고 처리 부하도 큽니다. CoAP와 함께 사용하기에 권장되는 콘텐츠 형식 중 하나는 CBOR로, 이러한 환경에서 사용되도록 설계되었습니다.

payload(), QCborStreamWriter 및 QCborStreamReader도 참조하십시오 .

void QCoapMessage::setToken(const QByteArray &token)

메시지 토큰을 token 로 설정합니다.

token()도 참조하십시오 .

void QCoapMessage::setType(const QCoapMessage::Type &type)

메시지 유형을 ‘ type ’로 설정합니다.

type()도 참조하십시오 .

void QCoapMessage::setVersion(quint8 version)

CoAP 버전을 version 로 설정합니다.

version()도 참조하십시오 .

[noexcept] void QCoapMessage::swap(QCoapMessage &other)

이 메시지를 other 로 교체합니다. 이 작업은 매우 빠르며 절대 실패하지 않습니다.

QByteArray QCoapMessage::token() const

메시지 토큰을 반환합니다.

setToken()도 참조하십시오 .

quint8 QCoapMessage::tokenLength() const

토큰의 길이를 반환합니다.

QCoapMessage::Type QCoapMessage::type() const

메시지 유형을 반환합니다.

setType()도 참조하십시오 .

quint8 QCoapMessage::version() const

CoAP 버전을 반환합니다.

setVersion()도 참조하십시오 .

[noexcept] QCoapMessage &QCoapMessage::operator=(QCoapMessage &&other)

other 를 이 메시지로 이동시키고, 이 QCoapMessage 에 대한 참조를 반환합니다.

QCoapMessage &QCoapMessage::operator=(const QCoapMessage &other)

other 의 내용을 이 메시지로 복사합니다. 이 QCoapMessage 에 대한 참조를 반환합니다.

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