QCoapReply Class
The QCoapReply class holds the data of a CoAP reply. More...
Header: | #include <QCoapReply> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Coap) target_link_libraries(mytarget PRIVATE Qt6::Coap) |
qmake: | QT += coap |
Inherits: | QIODevice |
Inherited By: |
Note: All functions in this class are reentrant.
Public Functions
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 |
Signals
void | aborted(const QCoapToken &token) |
void | error(QCoapReply *reply, QtCoap::Error error) |
void | finished(QCoapReply *reply) |
void | notified(QCoapReply *reply, const QCoapMessage &message) |
Detailed Description
The QCoapReply contains data related to a request sent with the QCoapClient.
The finished() signal is emitted when the response is fully received or when the request fails.
For Observe requests specifically, the notified() signal is emitted whenever a notification is received.
See also QCoapClient, QCoapRequest, and QCoapResourceDiscoveryReply.
Member Function Documentation
[override virtual noexcept]
QCoapReply::~QCoapReply()
Destroys the QCoapReply and aborts the request if its response has not yet been received.
void QCoapReply::abortRequest()
Aborts the request immediately and emits the aborted(const QCoapToken &token) signal if the request was not finished.
[signal]
void QCoapReply::aborted(const QCoapToken &token)
This signal is emitted when the request is aborted or the reply is deleted. Its token parameter is the token of the exchange that has been aborted.
Note: If the QCoapReply is deleted while not finished, both aborted() and finished() signal will be emitted immediately before the QCoapReply is destroyed. Given the QCoapReply may have been deleted when receiving the signal, you should not rely on the sender() object to be still valid.
See also finished() and error().
[signal]
void QCoapReply::error(QCoapReply *reply, QtCoap::Error error)
This signal is emitted whenever an error occurs and is followed by the finished() signal.
Its reply parameters is the QCoapReply itself for convenience, and the error parameter is the error received.
See also finished() and aborted().
QtCoap::Error QCoapReply::errorReceived() const
Returns the error of the reply or QCoapReply::NoError if there is no error.
[signal]
void QCoapReply::finished(QCoapReply *reply)
This signal is emitted whenever the corresponding request finished, whether successfully or not. When a resource is observed, this signal will only be emitted once, when the observation ends.
The reply parameter is the QCoapReply itself for convenience.
Note: If the QCoapReply is deleted while not finished, both aborted() and finished() signal will be emitted immediately before the QCoapReply is destroyed. Given the QCoapReply may have been deleted when receiving the signal, you should not rely on the reply to be still valid.
See also QCoapClient::finished(), isFinished(), notified(), and aborted().
bool QCoapReply::isAborted() const
Returns true
if the request has been aborted.
bool QCoapReply::isFinished() const
Returns true
if the request is finished.
See also finished().
bool QCoapReply::isRunning() const
Returns true
if the request is running.
bool QCoapReply::isSuccessful() const
Returns true
if the request finished with no error.
QCoapMessage QCoapReply::message() const
Returns the contained message.
QtCoap::Method QCoapReply::method() const
Returns the method of the associated request.
[signal]
void QCoapReply::notified(QCoapReply *reply, const QCoapMessage &message)
This signal is emitted whenever a notification is received from an observed resource.
Its message parameter is a QCoapMessage containing the payload and the message details. The reply parameter is the QCoapReply itself for convenience.
See also QCoapClient::finished(), isFinished(), finished(), and notified().
QCoapRequest QCoapReply::request() const
Returns the associated request.
QtCoap::ResponseCode QCoapReply::responseCode() const
Returns the response code of the request.
QUrl QCoapReply::url() const
Returns the target uri of the associated request.
© 2024 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.