TsgcWSPClient_MQTTイベント › OnMQTTPubRec

OnMQTTPubRec イベント

QoS 2 ハンドシェイクの第 2 レッグ(PUBLISH → PUBREC → PUBREL → PUBCOMP)で発生します。

構文

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

デフォルト値

解説

QoS 2 は 4 パケットハンドシェイク (PUBLISH → PUBREC → PUBREL → PUBCOMP) を介してちょうど 1 回の配信を保証します。OnMQTTPubRec は、ブローカーが PUBREC パケットで元の PUBLISH を確認応答し、ちょうど 1 回のフローのためにブローカーがメッセージを受け入れたことを示すときに発生します。コンポーネントは自動的に PUBREL でハンドシェイクを続行します。最終的な PUBCOMP は OnMQTTPubComp で届きます。パラメータ:

使用例

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;

イベントに戻る