TsgcQUICServer › Events › OnQUICData
Fires when application data is received from a peer over its default QUIC stream.
property OnQUICData: TsgcQUICServerDataEvent;
// TsgcQUICServerDataEvent = procedure(Sender: TObject; const aConnection: TsgcQUICServerConnection; const aData: TBytes) of object
—
| Name | Type | Description |
|---|---|---|
Sender | TObject | The TsgcQUICServer instance. |
aConnection | const TsgcQUICServerConnection | The connection the bytes came from, and the handle to reply on. See TsgcQUICServerConnection. |
aData | const TBytes | The chunk read on this pass, at most 8192 bytes. Not a message boundary, see the Remarks. |
OnQUICData is raised whenever application bytes are read from the connection's default QUIC stream, the first bidirectional stream the peer opened. Bytes arriving on any other stream are reported by OnQUICStreamData instead, and only in multi-stream mode.
aData is a chunk, not a message. The server reads in blocks of up to 8192 bytes and raises the event once per block, so a logical message may be split across several calls, and several small messages may arrive in one. QUIC guarantees ordering within a stream but frames nothing for you, so if your protocol has message boundaries, buffer per connection and reassemble at the application level.
Reply by calling WriteData with the same aConnection, which is always safe from this event because the default stream exists by definition here.
This event runs on the server's background listener thread, and the whole QUIC event loop is blocked while your handler runs, for every connection, not just this one. Keep the handler short, and marshal to the main thread before touching the UI. An exception raised here is caught and surfaced through OnQUICException.
TsgcHTTP3Server wires this event to its own handler in its constructor, so do not assign it on an HTTP/3 server, use the HTTP/3 events instead.
procedure OnQUICDataEvent(Sender: TObject; const aConnection: TsgcQUICServerConnection; const aData: TBytes);
begin
// echo the received bytes back to the peer
oServer.WriteData(aConnection, aData);
end;