TsgcQUICClient › Events › OnQUICConnect
Fires once the QUIC connection has been established and the client is ready to send data.
property OnQUICConnect: TsgcQUICConnectEvent;
// TsgcQUICConnectEvent = procedure(Sender: TObject;
// const Connection: TsgcQUICConnection) of object;
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcQUICClient instance that raised the event. |
Connection | const TsgcQUICConnection | The QUIC connection that has just been established. Exposes State, PMTU and DestinationConnectionId. In .NET the parameter is a TsgcQUICClientConnection and may be null. |
OnQUICConnect is raised after the UDP socket has been opened and the TLS 1.3 handshake has succeeded, so the client is ready to send. It is the point at which Connect stops blocking and returns True, and the right place to send your first data with WriteData or to call EnableMultiStream if you need more than the default stream.
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. In .NET the dispatch honours the NotifyEvents property, and neSynchronous posts to the captured synchronization context.
The Connection parameter is typed as the base TsgcQUICConnection, not as a client-specific class. Do not free it, the component owns its lifetime.
oClient.OnQUICConnect := OnQUICConnectEvent;
oClient.Connect;
procedure OnQUICConnectEvent(Sender: TObject; const Connection: TsgcQUICConnection);
begin
Log('QUIC connected, PMTU ' + IntToStr(Connection.PMTU));
TsgcQUICClient(Sender).WriteData(TEncoding.UTF8.GetBytes('Hello QUIC'));
end;