TsgcQUICServer › Events › OnQUICDisconnect

OnQUICDisconnect Event

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

Syntax

property OnQUICDisconnect: TsgcQUICServerDisconnectEvent;
// TsgcQUICServerDisconnectEvent = procedure(Sender: TObject; const aConnection: TsgcQUICServerConnection; aCode: Int64; const aReason: string) of object

Default Value

—

Parameters

NameTypeDescription
SenderTObjectThe TsgcQUICServer instance.
aConnectionconst TsgcQUICServerConnectionThe connection being closed. It is still readable inside the handler but is freed right afterwards. See TsgcQUICServerConnection.
aCodeInt640 on a normal close. On a failure it carries the OpenSSL error code returned by SSL_get_error, not a QUIC application error code.
aReasonconst stringAn empty string on a normal close, otherwise the fixed literal 'SSL error'. It is not a peer-supplied reason phrase.

Remarks

OnQUICDisconnect is raised when the server stops servicing a connection, in one of two cases:

The event is not raised for connections dropped by Stop, which clears the whole connection list at once. So do not rely on it to run per-session cleanup at shutdown, do that around your Stop call instead.

After the handler returns, the connection is removed from the server and freed. Release any per-session context here and drop every reference to aConnection, using it afterwards reads freed memory.

The Delphi aCode and aReason carry OpenSSL diagnostics rather than QUIC-level information. In .NET the same parameters carry the QUIC application error code and the exception message, and .NET does raise the event when a connection is closed by Stop.

This event runs on the server's background listener thread, so marshal to the main thread before touching the UI.

Example


procedure OnQUICDisconnectEvent(Sender: TObject; const aConnection: TsgcQUICServerConnection; aCode: Int64; const aReason: string);
begin
  Log('QUIC disconnected: ' + aReason);
end;

Back to Events