TsgcQUICServer › Events › OnQUICConnect
Fires when a new QUIC connection has been accepted and its first stream is ready.
property OnQUICConnect: TsgcQUICServerConnectEvent;
// TsgcQUICServerConnectEvent = procedure(Sender: TObject; const aConnection: TsgcQUICServerConnection) of object
—
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcQUICServer instance. |
aConnection | const TsgcQUICServerConnection | The accepted connection, and the handle you pass to WriteData. See TsgcQUICServerConnection. |
OnQUICConnect is raised once per connection, after the QUIC handshake has completed and the peer's first stream has been accepted. The notification is deliberately deferred until that stream exists, so any bytes written from the handler with WriteData have a stream to target. A peer that connects but never opens a stream is therefore never announced, although it is already counted by ConnectionCount.
A connection refused because QUICOptions.MaxConnections was reached is dropped without raising this event.
Do not log aConnection.PeerIP in Delphi, it is always empty, because OpenSSL exposes no getter for the peer address of a connection accepted through its QUIC listener API. Use the connection instance itself as the session key. The peer endpoint is populated in .NET. See TsgcQUICServerConnection for the details.
This event runs on the server's background listener thread, so marshal to the main thread before touching the UI.
procedure OnQUICConnectEvent(Sender: TObject; const aConnection: TsgcQUICServerConnection);
begin
// PeerIP is not filled in by the Delphi server, so key on the instance
Log(Format('QUIC connected at %s (%d live)',
[DateTimeToStr(aConnection.CreatedAt), oServer.ConnectionCount]));
oServer.WriteData(aConnection, TEncoding.UTF8.GetBytes('welcome'));
end;