The QCoapMessage class holds information about a CoAP message that can be a request or a reply. 更多...
| 頭: |
#include <QCoapMessage>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Coap)
target_link_libraries(mytarget PRIVATE Qt6::Coap)
|
| qmake: |
QT += coap
|
| 繼承者: |
注意: 此類的所有函數 可重入 .
| 枚舉類 | 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 ) |
It holds information such as the message type, message id, token and other ancillary data.
另請參閱 QCoapOption , QCoapReply ,和 QCoapRequest .
Indicates the type of the message.
| 常量 | 值 | 描述 |
|---|---|---|
QCoapMessage::Type::Confirmable
|
0
|
A Confirmable message. The destination endpoint needs to acknowledge the message. |
QCoapMessage::Type::NonConfirmable
|
1
|
A Non-Confirmable message. The destination endpoint does not need to acknowledge the message. |
QCoapMessage::Type::Acknowledgment
|
2
|
An Acknowledgment message. A message sent or received in reply to a Confirmable message. |
QCoapMessage::Type::Reset
|
3
|
A Reset message. This message type is used in case of errors or to stop the ongoing transmission. (For example, it is used to cancel an observation). |
Constructs a new QCoapMessage.
構造淺拷貝為 other .
[noexcept]
QCoapMessage::
~QCoapMessage
()
銷毀 QCoapMessage .
Adds the given CoAP option .
Adds the CoAP option with the given name and value .
這是重載函數。
Removes all options.
返迴
true
if the message contains at last one option with
name
.
Returns the message id.
另請參閱 setMessageId ().
Finds and returns the first option with the given name . If there is no such option, returns an invalid QCoapOption with an empty value.
Returns the option at index position.
Returns the number of options.
Returns the list of options.
另請參閱 setOptions ().
Finds and returns the list of options with the given name .
Returns the payload.
另請參閱 setPayload ().
Removes all options with the given name . The CoAP protocol allows for the same option to repeat.
移除給定 option .
Sets the message ID to id .
另請參閱 messageId ().
Sets the message options to options .
另請參閱 options ().
Sets the message payload to payload . The payload can be represented in one of the content formats defined in CoAP Content-Formats Registry .
注意: CoAP supports common content formats such as XML, JSON, and so on, but these are text based and consequently heavy both in payload and in processing. One of the recommended content formats to use with CoAP is CBOR, which is designed to be used in such contexts.
另請參閱 payload (), QCborStreamWriter ,和 QCborStreamReader .
Sets the message token to token .
另請參閱 token ().
Sets the message type to type .
另請參閱 type ().
Sets the CoAP version to version .
另請參閱 version ().
[noexcept]
void
QCoapMessage::
swap
(
QCoapMessage
&
other
)
Swaps this message with other 。此操作很快且從不失敗。
Returns the message token.
另請參閱 setToken ().
Returns the token length.
Returns the message type.
另請參閱 setType ().
Returns the CoAP version.
另請參閱 setVersion ().
[noexcept]
QCoapMessage
&QCoapMessage::
operator=
(
QCoapMessage
&&
other
)
移動 other into this message and returns a reference to this QCoapMessage .
Copies the contents of other into this message. Returns a reference to this QCoapMessage .