TsgcQUICClient › Events › OnQUICDisconnect

OnQUICDisconnect Event

Fires when the QUIC connection has been closed, reporting the close code and reason.

Syntax

property OnQUICDisconnect: TsgcQUICDisconnectEvent;

// TsgcQUICDisconnectEvent = procedure(Sender: TObject;
//   const Connection: TsgcQUICConnection; Code: Int64; const Reason: string) of object;

Parameters

NameTypeDescription
SenderTObjectThe TsgcQUICClient instance that raised the event.
Connectionconst TsgcQUICConnectionThe connection that was closed. In .NET the parameter is a TsgcQUICClientConnection and may be null.
CodeInt64QUIC connection close code. 0 means NO_ERROR, a clean close. Non-zero values are the transport or application error codes of RFC 9000 section 20, for example 1 INTERNAL_ERROR, 2 CONNECTION_REFUSED, 3 FLOW_CONTROL_ERROR, and 0x0100 and above CRYPTO_ERROR. It is 0 when the local application requested the close.
Reasonconst stringHuman readable reason phrase reported with the close, empty when none was supplied.

Remarks

OnQUICDisconnect is raised after the connection has closed, whether the close was requested locally through Disconnect or Active, requested by the server, or caused by a transport error. Inspect Code to tell a clean shutdown from a failure and decide whether to reconnect. When the close is initiated locally the component reports Code as 0 and Reason as an empty string.

The event is raised from the connection read thread. The component sets NotifyEvents to neNoSync, so the handler does not run on the main thread: never touch VCL or FMX controls directly from it, marshal to the main thread instead.

Do not free the Connection parameter, and do not hold a reference to it beyond the handler, the component tears it down as part of the disconnect.

Example


oClient.OnQUICDisconnect := OnQUICDisconnectEvent;

procedure OnQUICDisconnectEvent(Sender: TObject; const Connection: TsgcQUICConnection;
  Code: Int64; const Reason: string);
begin
  if Code = 0 then
    Log('QUIC closed cleanly')
  else
    Log(Format('QUIC closed, code %d: %s', [Code, Reason]));
end;

Back to Events