TsgcWSPClient_MQTTEvents › OnMQTTSubscribe

OnMQTTSubscribe Event

Fires when a SUBACK is received in response to Subscribe; exposes per-topic reason codes and MQTT 5 SubscribeProperties.

Syntax

property OnMQTTSubscribe: TsgcWSMQTTSubscribeEvent;
// TsgcWSMQTTSubscribeEvent = procedure(Connection: TsgcWSConnection; aPacketIdentifier: Word; aCodes: TsgcWSSUBACKS; SubscribeProperties: TsgcWSMQTTSUBACKProperties) of object

Default Value

Remarks

Raised when the broker replies with a SUBACK to a SUBSCRIBE request. The broker can accept, partially accept or reject individual topic filters in the request, so the event delivers a code per filter. Parameters:

Example

procedure TForm1.MQTTSubscribe(Connection: TsgcWSConnection;
  aPacketIdentifier: Word; aCodes: TsgcWSSUBACKS;
  SubscribeProperties: TsgcWSMQTTSUBACKProperties);
var
  i: Integer;
begin
  for i := 0 to Length(aCodes) - 1 do
    if aCodes[i] < $80 then
      Memo1.Lines.Add(Format('subscription %d accepted (QoS %d)',
        [i, aCodes[i]]))
    else
      Memo1.Lines.Add(Format('subscription %d rejected (code $%x)',
        [i, aCodes[i]]));
end;

Back to Events