QCoapReply Class
QCoapReply 类保存 CoAP 回复的数据。更多
头文件: | #include <QCoapReply> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Coap) target_link_libraries(mytarget PRIVATE Qt6::Coap) |
qmake: | QT += coap |
继承: | QIODevice |
继承于: |
注意:该类中的所有函数都是可重入的。
公共函数
virtual | ~QCoapReply() override |
void | abortRequest() |
QtCoap::Error | errorReceived() const |
bool | isAborted() const |
bool | isFinished() const |
bool | isRunning() const |
bool | isSuccessful() const |
QCoapMessage | message() const |
QtCoap::Method | method() const |
QCoapRequest | request() const |
QtCoap::ResponseCode | responseCode() const |
QUrl | url() const |
信号
void | aborted(const QCoapToken &token) |
void | error(QCoapReply *reply, QtCoap::Error error) |
void | finished(QCoapReply *reply) |
void | notified(QCoapReply *reply, const QCoapMessage &message) |
详细说明
QCoapReply 包含与通过QCoapClient 发送的请求相关的数据。
当完全收到响应或请求失败时,会发出finished() 信号。
具体到Observe请求,只要收到通知,就会发出notified() 信号。
另请参阅 QCoapClient,QCoapRequest, 和QCoapResourceDiscoveryReply 。
成员函数文档
[override virtual noexcept]
QCoapReply::~QCoapReply()
销毁QCoapReply ,如果尚未收到响应,则终止请求。
void QCoapReply::abortRequest()
立即终止请求,如果请求未完成,则发出aborted(const QCoapToken &token) 信号。
[signal]
void QCoapReply::aborted(const QCoapToken &token)
该信号在请求中止或回复被删除时发出。其token 参数是已中止的交换的标记。
注意: 如果QCoapReply 在未完成时被删除,则 aborted() 和finished() 信号都会在QCoapReply 销毁前立即发出。鉴于QCoapReply 在收到信号时可能已被删除,因此不应依赖sender() 对象是否仍然有效。
[signal]
void QCoapReply::error(QCoapReply *reply, QtCoap::Error error)
每当发生错误时,就会发出该信号,之后是finished() 信号。
为方便起见,其reply 参数是QCoapReply 本身,而error 参数是收到的错误信息。
QtCoap::Error QCoapReply::errorReceived() const
返回回复的错误信息,如果没有错误,则返回 QCoapReply::NoError 信息。
[signal]
void QCoapReply::finished(QCoapReply *reply)
无论请求成功与否,只要相应请求结束,就会发出该信号。在观察资源时,该信号只会在观察结束时发出一次。
为方便起见,reply 参数就是QCoapReply 本身。
注意: 如果QCoapReply 在未完成时被删除,则aborted() 和 finished() 信号都会在QCoapReply 销毁前立即发出。鉴于QCoapReply 在收到信号时可能已被删除,因此不应依赖reply 仍然有效。
另请参阅 QCoapClient::finished()、isFinished()、notified() 和aborted()。
bool QCoapReply::isAborted() const
如果请求已中止,则返回true
。
bool QCoapReply::isFinished() const
如果请求已完成,则返回true
。
另请参阅 finished().
bool QCoapReply::isRunning() const
如果请求正在运行,则返回true
。
bool QCoapReply::isSuccessful() const
如果请求无误完成,则返回true
。
QCoapMessage QCoapReply::message() const
返回包含的信息。
QtCoap::Method QCoapReply::method() const
返回相关请求的方法。
[signal]
void QCoapReply::notified(QCoapReply *reply, const QCoapMessage &message)
每当收到来自被观测资源的通知时,就会发出该信号。
message 参数是QCoapMessage ,其中包含有效载荷和信息详情。为方便起见,reply 参数本身就是QCoapReply 。
另请参阅 QCoapClient::finished()、isFinished()、finished() 和 notified()。
QCoapRequest QCoapReply::request() const
返回相关请求。
QtCoap::ResponseCode QCoapReply::responseCode() const
返回请求的响应代码。
QUrl QCoapReply::url() 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.