TsgcQUICClient › Events › OnQUICDisconnect
Fires when the QUIC connection has been closed, reporting the close code and reason.
property OnQUICDisconnect: TsgcQUICDisconnectEvent;
// TsgcQUICDisconnectEvent = procedure(Sender: TObject;
// const Connection: TsgcQUICConnection; Code: Int64; const Reason: string) of object;
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcQUICClient instance that raised the event. |
Connection | const TsgcQUICConnection | The connection that was closed. In .NET the parameter is a TsgcQUICClientConnection and may be null. |
Code | Int64 | QUIC 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. |
Reason | const string | Human readable reason phrase reported with the close, empty when none was supplied. |
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.
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;