TsgcWSPClient_MQTT › イベント › OnMQTTPublish
ブローカーが受信 PUBLISH メッセージを配信したときに発火します。Topic、Text、MQTT 5 の PublishProperties を公開します。
property OnMQTTPublish: TsgcWSMQTTPublishEvent;
// TsgcWSMQTTPublishEvent = procedure(Connection: TsgcWSConnection; aTopic, aText: String; PublishProperties: TsgcWSMQTTPUBLISHProperties) of object
—
メインの配信イベント: ブローカーがサブスクリプションの1つに一致するトピックに対してPUBLISHをこのクライアントに転送するたびに発生します。パブリッシュQoS(0、1、2)に関わらず、イベントはトランスポートレベルの確認応答シーケンスが完了した後に発火します。QoS 0は発射忘れ、QoS 1はPUBACK後、QoS 2はPUBREC/PUBREL/PUBCOMPの交換後です。パラメータ:
procedure TForm1.MQTTPublish(Connection: TsgcWSConnection;
aTopic, aText: String;
PublishProperties: TsgcWSMQTTPUBLISHProperties);
begin
Memo1.Lines.Add(Format('[%s] %s', [aTopic, aText]));
// MQTT 5: honour a ResponseTopic if the sender set one
if PublishProperties.ResponseTopic <> '' then
MQTT.Publish(PublishProperties.ResponseTopic, 'ack', mtqsAtMostOnce);
end;