TsgcWSPClient_MQTTEvents › OnMQTTUnSubscribe

OnMQTTUnSubscribe Event

Fires when an UNSUBACK is received in response to UnSubscribe; exposes per-topic reason codes and MQTT 5 UnsubscribeProperties.

Syntax

property OnMQTTUnSubscribe: TsgcWSMQTTUnSubscribeEvent;
// TsgcWSMQTTUnSubscribeEvent = procedure(Connection: TsgcWSConnection; aPacketIdentifier: Word; aCodes: TsgcWSUNSUBACKS; UnsubscribeProperties: TsgcWSMQTTUNSUBACKProperties) of object

Default Value

Remarks

Raised when the broker replies with an UNSUBACK to an UNSUBSCRIBE request. In MQTT 3.1.1 UNSUBACK carries no status; in MQTT 5.0 it carries one reason code per topic filter so the server can report "no subscription existed" or "not authorized" per-topic. Parameters:

Example

procedure TForm1.MQTTUnSubscribe(Connection: TsgcWSConnection;
  aPacketIdentifier: Word; aCodes: TsgcWSUNSUBACKS;
  UnsubscribeProperties: TsgcWSMQTTUNSUBACKProperties);
var
  i: Integer;
begin
  for i := 0 to Length(aCodes) - 1 do
    Memo1.Lines.Add(Format('unsubscribe %d result=$%x',
      [i, aCodes[i]]));
end;

Back to Events