TsgcWSPClient_MQTTEvents › OnMQTTPing

OnMQTTPing Event

Fires when the client receives a PINGRESP acknowledging a previously sent PINGREQ.

Syntax

property OnMQTTPing: TsgcWSMQTTPingEvent;
// TsgcWSMQTTPingEvent = procedure(Connection: TsgcWSConnection) of object

Default Value

Remarks

Confirms that the broker replied with PINGRESP to a PINGREQ. The client sends PINGREQ automatically when HeartBeat is enabled (the default) at the configured Interval; if HeartBeat is disabled you can call the Ping method manually and still receive this event on the response. Use it to surface keep-alive activity in logs or UI. If HeartBeat.Timeout elapses without a PINGRESP the connection is closed automatically and OnMQTTDisconnect fires instead.

Example

procedure TForm1.MQTTPing(Connection: TsgcWSConnection);
begin
  Memo1.Lines.Add(Format('[%s] PINGRESP from broker',
    [FormatDateTime('hh:nn:ss', Now)]));
end;

Back to Events