TsgcWSPClient_MQTTEventi › OnMQTTPubRec

OnMQTTPubRec Evento

Si attiva al secondo passaggio dell'handshake QoS 2 (PUBLISH → PUBREC → PUBREL → PUBCOMP).

Sintassi

property OnMQTTPubRec: TsgcWSMQTTPubRecEvent;
// TsgcWSMQTTPubRecEvent = procedure(Connection: TsgcWSConnection; aPacketIdentifier: Word; ReasonCode: Integer; const ReasonName: String; PubRecProperties: TsgcWSMQTTPUBRECProperties) of object

Valore predefinito

Note

QoS 2 garantisce la consegna esattamente una volta tramite un handshake a quattro pacchetti: PUBLISH → PUBREC → PUBREL → PUBCOMP. OnMQTTPubRec si attiva quando il broker conferma il PUBLISH originale con un pacchetto PUBREC, segnalando che il broker ha accettato il messaggio per il flusso exactly-once. Il componente risponde automaticamente con PUBREL per continuare l'handshake; il PUBCOMP finale arriverà su OnMQTTPubComp. Parametri:

Esempio

procedure TForm1.MQTTPubRec(Connection: TsgcWSConnection;
  aPacketIdentifier: Word; ReasonCode: Integer;
  const ReasonName: String;
  PubRecProperties: TsgcWSMQTTPUBRECProperties);
begin
  // second leg of QoS 2: broker has the message, PUBREL is sent automatically
  Memo1.Lines.Add(Format('PUBREC id=%d (%s)',
    [aPacketIdentifier, ReasonName]));
end;

Torna agli Eventi