TsgcWebTransportSession › Methods › Create
Constructs a session bound to a session id. The HTTP/3 client and server call this for you; applications do not.
constructor Create(aSessionId: Int64); virtual;
| Name | Type | Description |
|---|---|---|
aSessionId | Int64 | The QUIC stream id of the Extended CONNECT request that established the session. It becomes the read-only SessionId and anchors every stream header and datagram prefix in the session. |
You do not call this. A session only means anything when it is wired to a live QUIC connection, and that wiring is not part of the constructor. Sessions reach you already built:
TsgcHTTP3Client.WebTransportConnect constructs one with the CONNECT stream id after a :status = 200, assigns the three transport hooks, and adds it to WebTransportSessions.OnWebTransportSession so you can accept or reject it.
The constructor itself only sets SessionId and creates the internal stream list and its critical section. It assigns no transport hooks. A session you construct yourself has no way to write to a connection: OpenStream would create streams whose bytes go nowhere. It is public and virtual so that a custom QUIC transport can build and wire a session itself, and so a descendant can extend it.
Ownership. The connection's session registry owns the session and frees it, and the session's destructor frees the stream list along with every stream in it. Never free a session yourself, and never keep a reference to one, or to any of its streams, past the lifetime of the client or connection that owns it. On the client, freeing the TsgcHTTP3Client releases every session and every stream underneath.
This member is currently available in the Delphi/C++Builder implementation only. The .NET class has an equivalent constructor, but it is internal and cannot be called from application code.
// Applications never construct a session. They receive one:
// Client: WebTransportConnect builds and wires it, or returns nil.
FSession := FClient.WebTransportConnect('https://127.0.0.1:4433/echo');
if Assigned(FSession) then
FSession.OnStream := OnWTStream;
// FSession is owned by FClient.WebTransportSessions. Do not free it.
// Server: the session arrives already built and wired.
procedure TfrmServer.OnWTSession(Sender: TObject;
const aConnection: TsgcQUICServerConnection;
const aSession: TsgcWebTransportSession; var aAccept: Boolean);
begin
aAccept := True; // accept; the server registers and owns it
aSession.OnStream := OnWTStream;
end;