Loading...
Searching...
No Matches
mqtt::subscribe_response Struct Reference

`#include <server_response.h>`

Inheritance diagram for mqtt::subscribe_response:

## Public Member Functions

| subscribe_response (MQTTAsync_successData5 *rsp)
| subscribe_response (size_t n, MQTTAsync_successData *rsp)
const std::vector< ReasonCode > & | get_reason_codes () const
Public Member Functions inherited from mqtt::server_response
| server_response ()
| server_response (const properties &props)
| server_response (properties &&props)
virtual | ~server_response ()
const properties & | get_properties () const noexcept

## Data Fields

std::vector< ReasonCode > | reasonCodes_

## Friends

class | token

## Detailed Description

Response for a subscribe request.

This contains the information returned from the broker in the SUBACK packet. It gives information about the granted Qos for each topc in the subscribe request.

- MQTT v3: These are return "codes" with the value 0-2 for each of the topic filters sent in the subscribe message.
- MQTT v5 These are reason codes, with one for each of the topics sent in the subscribe message. On success, the values are the same as for MQTT v3: the granted QoS 0-2. For errors, each could be an error code with a value >= 0x80, as described in the MQTT v5 spec: (not authorized, quota exceeded, etc).

## Constructor & Destructor Documentation

## subscribe_response() [1/2]

mqtt::subscribe_response::subscribe_response | ( | MQTTAsync_successData5 * | rsp | ) |

Create v5 subscribe response.

Parameters

  rsp | The v5 response struct from the C lib

## subscribe_response() [2/2]

mqtt::subscribe_response::subscribe_response | ( | size_t | n,
|  | MQTTAsync_successData * | rsp
| ) |  |

Create v3 subscribe response.

Parameters

  n | The number of subscription topics
  rsp | The v3 response struct from the C lib

## Member Function Documentation

## get_reason_codes()

const std::vector< ReasonCode > & mqtt::subscribe_response::get_reason_codes | ( |  | ) | const

inline

Gets the reason codes from the server response.

On a subscribe ack there is a return/reason code for each topic that was sent in the subscribe packet. Each tells the granted QoS for the corresponding topic.

For MQTT v5 values over 0x80 are error codes as descibed in the MQTT v5 spec.

Returns
  A collection of return/reason codes corresponding to subscribing each topic. On success, this is the granted QoS for each topic. On failure it is the reason for the failure.

## Friends And Related Symbol Documentation

## token

friend class token

friend

## Field Documentation

## reasonCodes_

std::vector<ReasonCode> mqtt::subscribe_response::reasonCodes_

The reason/result code for each topic request.

The documentation for this struct was generated from the following file:

- server_response.h