TsgcQUICClient › Events › OnQUICStreamData
Fires with the bytes read from an additional QUIC stream once multi-stream mode has been enabled.
property OnQUICStreamData: TsgcQUICClientStreamDataEvent;
// TsgcQUICClientStreamDataEvent = procedure(Sender: TObject; aStreamId: Int64;
// aUnidirectional: Boolean; const aData: TBytes) of object;
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcQUICClient instance that raised the event. |
aStreamId | Int64 | QUIC stream identifier the bytes were read from. Use it to demultiplex data when several streams are open at the same time. |
aUnidirectional | Boolean | True when the stream is unidirectional, so nothing can be written back on it. False for a bidirectional stream. |
aData | const TBytes | The bytes read from the stream. QUIC does not preserve application message boundaries, so a logical message may arrive split over several events. |
OnQUICStreamData is the only read path exposed by TsgcQUICClient, and it is inert until EnableMultiStream has been called. A plain QUIC client keeps its single-stream behaviour and never raises it. Call EnableMultiStream once the connection is up, for example inside OnQUICConnect, and the client then harvests both the streams the peer opens and the streams you open with OpenStream, raising this event for each block of bytes read.
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.
This member is currently available in the Delphi/C++Builder implementation only, and it requires the builtin OpenSSL QUIC engine. See TsgcQUICClient for the difference between the two QUIC engines.
oClient.OnQUICConnect := OnQUICConnectEvent;
oClient.OnQUICStreamData := OnQUICStreamDataEvent;
oClient.Connect;
procedure OnQUICConnectEvent(Sender: TObject; const Connection: TsgcQUICConnection);
begin
// required before any stream data is reported
TsgcQUICClient(Sender).EnableMultiStream;
end;
procedure OnQUICStreamDataEvent(Sender: TObject; aStreamId: Int64;
aUnidirectional: Boolean; const aData: TBytes);
begin
Log(Format('stream %d (%s): %d bytes', [aStreamId,
BoolToStr(aUnidirectional, True), Length(aData)]));
end;