Subscribed Event

Fires for each topic filter subscription the server acknowledges.

Syntax

public event OnSubscribedHandler OnSubscribed;

public delegate void OnSubscribedHandler(object sender, MqttSubscribedEventArgs e);

public class MqttSubscribedEventArgs : EventArgs {
  public string TopicFilter { get; }
  public int QOS { get; }
  public int ResponseCode { get; }
}
Public Event OnSubscribed As OnSubscribedHandler

Public Delegate Sub OnSubscribedHandler(sender As Object, e As MqttSubscribedEventArgs)

Public Class MqttSubscribedEventArgs Inherits EventArgs
  Public ReadOnly Property TopicFilter As String
  Public ReadOnly Property QOS As Integer
  Public ReadOnly Property ResponseCode As Integer
End Class

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.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 .NET Edition - Version 20.0 [Build 8265]