Represents a reply of a CoAP request. More...
Header: | #include <CoapReply> |
Inherits: |
enum | Error { NoError, HostNotFoundError, TimeoutError, InvalidUrlSchemeError, InvalidPduError } |
CoapPdu::ContentType | contentType() const |
Error | error() const |
QString | errorString() const |
bool | isFinished() const |
bool | isRunning() const |
CoapPdu::MessageType | messageType() const |
QByteArray | payload() const |
CoapRequest | request() const |
CoapPdu::StatusCode | statusCode() const |
Represents a reply of a CoAP request.
The CoapReply class contains the data and headers for a request sent with Coap client.
Note: Please don't forget to delete the reply once it is finished.
Coap *coap = new Coap(this); connect(coap, SIGNAL(replyFinished(CoapReply*)), this, SLOT(onReplyFinished(CoapReply*))); CoapRequest request(QUrl("coap://example.com/")); CoapReply *reply = coap->ping(request);
void MyClass::onReplyFinished(CoapReply *reply) { if (reply->error() != CoapReply::NoError) { qWarning() << "Reply finished with error" << reply->errorString(); reply->deleteLater(); return; } qDebug() << "Reply finished" << reply; reply->deleteLater(); }
See also Coap and CoapRequest.
Constant | Value | Description |
---|---|---|
CoapReply::NoError | 0 | No error occurred. Everything ok. |
CoapReply::HostNotFoundError | 1 | The remote host name was not found (invalid hostname). |
CoapReply::TimeoutError | 2 | The server did not respond after 4 retransmissions. |
CoapReply::InvalidUrlSchemeError | 3 | The given URL does not have a valid scheme. |
CoapReply::InvalidPduError | 4 | The package data unit (PDU) could not be parsed successfully. |
Returns the CoapPdu::ContentType of this CoapReply.
Returns error CoapReply::Error of the CoapReply.
See also errorString().
[signal]
void CoapReply::error(const Error & code)This signal is emitted when an error occurred. The given code represents the CoapReply::Error.
See also error() and errorString().
Returns error string of the CoapReply.
See also error().
[signal]
void CoapReply::finished()This signal is emitted when the reply is finished.
Returns true if the CoapReply is finished.
See also finished().
Returns true if the CoapReply is running.
See also finished().
Returns the CoapPdu::MessageType of this CoapReply.
Returns the payload of this CoapReply. The payload will be available once the CoapReply is finished.
See also isFinished.
Returns the request for this CoapReply.
Returns the CoapPdu::StatusCode of this CoapReply.
[signal]
void CoapReply::timeout()This signal is emitted when the reply took to long.