TsgcQUICServer › Events › OnQUICDisconnect
Fires when a QUIC connection has been closed, reporting the error code and reason.
property OnQUICDisconnect: TsgcQUICServerDisconnectEvent;
// TsgcQUICServerDisconnectEvent = procedure(Sender: TObject; const aConnection: TsgcQUICServerConnection; aCode: Int64; const aReason: string) of object
—
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcQUICServer instance. |
aConnection | const TsgcQUICServerConnection | The connection being closed. It is still readable inside the handler but is freed right afterwards. See TsgcQUICServerConnection. |
aCode | Int64 | 0 on a normal close. On a failure it carries the OpenSSL error code returned by SSL_get_error, not a QUIC application error code. |
aReason | const string | An empty string on a normal close, otherwise the fixed literal 'SSL error'. It is not a peer-supplied reason phrase. |
OnQUICDisconnect is raised when the server stops servicing a connection, in one of two cases:
aCode is 0 and aReason is empty. Note that in multi-stream mode (see AlwaysMultiStream) this case does not raise the event: ending a request stream does not end the connection there, so only the stream is released and the connection stays alive.aCode is the OpenSSL error code and aReason is 'SSL error'.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.
procedure OnQUICDisconnectEvent(Sender: TObject; const aConnection: TsgcQUICServerConnection; aCode: Int64; const aReason: string);
begin
Log('QUIC disconnected: ' + aReason);
end;