TsgcWSPClient_MQTTEventos › OnMQTTPubRec

OnMQTTPubRec Evento

Se activa en la segunda fase del protocolo de enlace QoS 2 (PUBLISH → PUBREC → PUBREL → PUBCOMP).

Sintaxis

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

Valor Predeterminado

Observaciones

QoS 2 garantiza la entrega exactamente una vez mediante un handshake de cuatro paquetes: PUBLISH → PUBREC → PUBREL → PUBCOMP. OnMQTTPubRec se activa cuando el broker reconoce el PUBLISH original con un paquete PUBREC, indicando que el broker ha aceptado el mensaje para el flujo exactamente una vez. El componente responde automáticamente con PUBREL para continuar el handshake; el PUBCOMP final llegará en OnMQTTPubComp. Parámetros:

Ejemplo

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;

Volver a Eventos