TsgcWebTransportSession › Methods › Create

Create Method

Constructs a session bound to a session id. The HTTP/3 client and server call this for you; applications do not.

Syntax

constructor Create(aSessionId: Int64); virtual;

Parameters

NameTypeDescription
aSessionIdInt64The 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.

Remarks

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:

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.

Example


// 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;

Back to Methods