QCoapInternalRequest Class

The QCoapInternalRequest class contains data related to a message that needs to be sent. More...

Header: #include <QCoapInternalRequest>
Inherits: QCoapInternalMessage

Public Functions

QCoapInternalRequest(QObject *parent = nullptr)
QCoapInternalRequest(const QCoapRequest &request, QObject *parent = nullptr)
bool addUriOptions(QUrl uri, const QUrl &proxyUri = QUrl())
bool checkBlockNumber(uint blockNumber)
QCoapConnection *connection() const
void initEmptyMessage(quint16 messageId, QCoapMessage::Type type)
bool isMulticast() const
bool isObserve() const
bool isObserveCancelled() const
QtCoap::Method method() const
void restartTransmission()
uint retransmissionCounter() const
void setConnection(QCoapConnection *connection)
void setMaxTransmissionWait(uint duration)
void setMessageId(quint16 id)
void setMethod(QtCoap::Method method)
void setMulticastTimeout(uint responseDelay)
void setObserveCancelled()
void setTargetUri(QUrl targetUri)
void setTimeout(uint timeout)
void setToRequestBlock(uint blockNumber, uint blockSize)
void setToSendBlock(uint blockNumber, uint blockSize)
void setToken(const QCoapToken &token)
void startMulticastTransmission()
void stopTransmission()
QUrl targetUri() const
QCoapToken token() const

Reimplemented Public Functions

virtual void addOption(const QCoapOption &option) override
virtual bool isValid() const override

Protected Functions

QCoapOption blockOption(QCoapOption::OptionName name, uint blockNumber, uint blockSize) const
QCoapOption uriHostOption(const QUrl &uri) const

Detailed Description

\internal

\reentrant

See also QCoapInternalMessage and QCoapInternalReply.

Member Function Documentation

[explicit] QCoapInternalRequest::QCoapInternalRequest(QObject *parent = nullptr)

\internalConstructs a new QCoapInternalRequest object and sets parent as the parent object.

[explicit] QCoapInternalRequest::QCoapInternalRequest(const QCoapRequest &request, QObject *parent = nullptr)

\internalConstructs a new QCoapInternalRequest object with the information of request and sets parent as the parent object.

[override virtual] void QCoapInternalRequest::addOption(const QCoapOption &option)

Reimplements: QCoapInternalMessage::addOption(const QCoapOption &option).

\internalAdds the given CoAP option and sets block parameters if needed.

bool QCoapInternalRequest::addUriOptions(QUrl uri, const QUrl &proxyUri = QUrl())

\internalAdds the CoAP options related to the target and proxy with the given uri and proxyUri. Returns true upon success, false if an error occurred.

Numbers refer to step numbers from CoAP https://tools.ietf.org/html/rfc7252#section-6.4.

[protected] QCoapOption QCoapInternalRequest::blockOption(QCoapOption::OptionName name, uint blockNumber, uint blockSize) const

\internalBuilds and returns a Block option.

The blockSize should range from 16 to 1024 and be a power of 2, computed as 2^(SZX + 4), with SZX ranging from 0 to 6. For more details, refer to the RFC 7959.

bool QCoapInternalRequest::checkBlockNumber(uint blockNumber)

\internalReturns true if the block number is valid, false otherwise. If the block number is not valid, logs a warning message.

QCoapConnection *QCoapInternalRequest::connection() const

\internalReturns the connection used to send this request.

See also setConnection().

void QCoapInternalRequest::initEmptyMessage(quint16 messageId, QCoapMessage::Type type)

\internalInitialize parameters to transform the QCoapInternalRequest into an empty message (RST or ACK) with the message id messageId.

An empty message should contain only the messageId.

bool QCoapInternalRequest::isMulticast() const

\internal

Returns true if the request is multicast, returns false otherwise.

bool QCoapInternalRequest::isObserve() const

\internalReturns true if the request is an Observe request.

bool QCoapInternalRequest::isObserveCancelled() const

\internalReturns true if the observe request needs to be cancelled.

See also setCancelObserve().

[override virtual] bool QCoapInternalRequest::isValid() const

Reimplements: QCoapInternalMessage::isValid() const.

\internalReturns true if the request is considered valid.

QtCoap::Method QCoapInternalRequest::method() const

\internalReturns the method of the request.

See also setMethod().

void QCoapInternalRequest::restartTransmission()

\internalUsed to mark the transmission as "in progress", when starting or retrying to transmit a message. This method manages the retransmission counter, the transmission timeout and the exchange timeout.

uint QCoapInternalRequest::retransmissionCounter() const

\internalReturns the value of the retransmission counter.

void QCoapInternalRequest::setConnection(QCoapConnection *connection)

\internalSets the connection to use to send this request to the given connection.

See also connection().

void QCoapInternalRequest::setMaxTransmissionWait(uint duration)

\internalSets the maximum transmission span for the request. If the request is not finished at the end of the transmission span, the request will timeout.

void QCoapInternalRequest::setMessageId(quint16 id)

\internalSets the request's message id.

void QCoapInternalRequest::setMethod(QtCoap::Method method)

\internalSets the method of the request to the given method.

See also method().

void QCoapInternalRequest::setMulticastTimeout(uint responseDelay)

\internal

Sets the timeout interval in milliseconds for keeping the multicast request alive.

In the unicast case, receiving a response means that the request is finished. In the multicast case it is not known how many responses will be received, so the response, along with its token, will be kept for NON_LIFETIME + MAX_LATENCY + MAX_SERVER_RESPONSE_DELAY time, as suggested in RFC 7390 - Section 2.5.

void QCoapInternalRequest::setObserveCancelled()

\internalMarks the observe request as cancelled.

See also isObserveCancelled().

void QCoapInternalRequest::setTargetUri(QUrl targetUri)

\internalSets the target uri to the given targetUri.

See also targetUri().

void QCoapInternalRequest::setTimeout(uint timeout)

\internalSets the timeout to the given timeout value in milliseconds. Timeout is used for reliable transmission of Confirmable messages.

When such request times out, its timeout value will double.

void QCoapInternalRequest::setToRequestBlock(uint blockNumber, uint blockSize)

\internalInitializes block parameters and creates the options needed to request the block blockNumber with a size of blockSize.

See also blockOption() and setToSendBlock().

void QCoapInternalRequest::setToSendBlock(uint blockNumber, uint blockSize)

\internalInitialize blocks parameters and creates the options needed to send the block with the number blockNumber and with a size of blockSize.

See also blockOption() and setToRequestBlock().

void QCoapInternalRequest::setToken(const QCoapToken &token)

\internalSets the request's token.

See also token().

void QCoapInternalRequest::startMulticastTransmission()

\internal

Starts the timer for keeping the multicast request alive.

void QCoapInternalRequest::stopTransmission()

\internalMarks the transmission as not running, after a successful reception or an error. It resets the retransmission count if needed and stops all timeout timers.

QUrl QCoapInternalRequest::targetUri() const

\internalReturns the target uri.

See also setTargetUri().

QCoapToken QCoapInternalRequest::token() const

\internalReturns the token of the request.

See also setToken().

[protected] QCoapOption QCoapInternalRequest::uriHostOption(const QUrl &uri) const

\internalDecode the uri provided and returns a QCoapOption.