Subscribed Event
Fires for each topic filter subscription the server acknowledges.
Syntax
ANSI (Cross Platform) virtual int FireSubscribed(MQTTSubscribedEventParams *e);
typedef struct {
const char *TopicFilter;
int QOS;
int ResponseCode; int reserved; } MQTTSubscribedEventParams; Unicode (Windows) virtual INT FireSubscribed(MQTTSubscribedEventParams *e);
typedef struct {
LPCWSTR TopicFilter;
INT QOS;
INT ResponseCode; INT reserved; } MQTTSubscribedEventParams;
- (void)onSubscribed:(NSString*)topicFilter :(int)QOS :(int)responseCode;
#define EID_MQTT_SUBSCRIBED 12 virtual INT IPWORKSIOT_CALL FireSubscribed(LPSTR &lpszTopicFilter, INT &iQOS, INT &iResponseCode);
Remarks
This event fires each time the server has acknowledged a topic filter subscription request (that is, calling Subscribe with multiple topic filters will cause this to fire multiple times).
- TopicFilter: The topic filter subscription request being acknowledged.
- QOS: The QoS level the server has granted for the subscription.
- ResponseCode: Indicates the result of the subscription request.
Possible values for ResponseCode are:
- 0: Success, QoS 0 granted
- 1: Success, QoS 1 granted
- 2: Success, QoS 2 granted
- 128: Unspecified error
- 131: Implementation specific error; The SUBSCRIBE is valid but the Server does not accept it.
- 135: Not authorized; The Client is not authorized to make this subscription.
- 143: Topic Filter invalid; The Topic Filter is correctly formed but is not allowed for this Client.
- 145: Packet Identifier in use
- 151: Quota exceeded; An implementation or administrative imposed limit has been exceeded.
- 158: Shared Subscriptions not supported
- 161: Shared Subscriptions not supported
- 162: Wildcard Subscriptions not supported
Keep in mind that the server may have chosen to grant a lower QoS than was requested under certain circumstances (e.g., if the server doesn't support the requested QoS).
Note: the server is not required to acknowledge a subscription before it begins delivering messages for that subscription.