TsgcWSPClient_MQTTEvents › OnMQTTPubComp

OnMQTTPubComp Event

Fires on the fourth and final leg of the QoS 2 handshake when a PUBCOMP is received.

Syntax

property OnMQTTPubComp: TsgcWSMQTTPubCompEvent;
// TsgcWSMQTTPubCompEvent = procedure(Connection: TsgcWSConnection; aPacketIdentifier: Word; ReasonCode: Integer; const ReasonName: String; PubCompProperties: TsgcWSMQTTPUBCOMPProperties) of object

Default Value

Remarks

Fires when the broker sends PUBCOMP, the fourth and final packet of the QoS 2 handshake (PUBLISH → PUBREC → PUBREL → PUBCOMP). At this point the exactly-once delivery is fully complete and the packet identifier can be reused. Parameters:

This is the event to listen to when you need to confirm that a QoS 2 publish has been fully processed end-to-end.

Example

procedure TForm1.MQTTPubComp(Connection: TsgcWSConnection;
  aPacketIdentifier: Word; ReasonCode: Integer;
  const ReasonName: String;
  PubCompProperties: TsgcWSMQTTPUBCOMPProperties);
begin
  // QoS 2 delivery is now complete
  Memo1.Lines.Add(Format('PUBCOMP id=%d delivered exactly-once',
    [aPacketIdentifier]));
end;

Back to Events