TsgcWebTransportSession › Properties › SessionId
QUIC stream id of the Extended CONNECT request that established this WebTransport session.
property SessionId: Int64 read FSessionId;
Int64 (__int64 in C++Builder, long in C#).
Assigned by the constructor. On the client it is the QUIC stream id of the CONNECT stream, or 0 when the transport reports no default stream id. On the server it is the request stream id the CONNECT arrived on.
Read-only. SessionId is set when the session object is constructed and never changes for the lifetime of the session.
WebTransport does not invent a session identifier. It reuses the QUIC stream id of the Extended CONNECT request that opened the session, because that stream id is already unique within the connection and both peers know it. That request stream stays open for as long as the session lives and carries no HTTP body.
The session id is the anchor for everything else on the wire. Every WebTransport stream is prefixed with a header naming its session:
| Stream kind | Header written on the QUIC stream |
|---|---|
| Unidirectional | varint(0x54) + varint(SessionId) |
| Bidirectional | varint(0x41) + varint(SessionId) (the WEBTRANSPORT_STREAM frame type) |
That is how a peer, on seeing a brand-new QUIC stream, works out which session it belongs to. The library writes and parses these headers for you. Datagrams use a compressed form of the same identity; see QuarterStreamId.
Do not confuse SessionId with TsgcWebTransportStream.StreamId. They are both QUIC stream ids, but the session id names the CONNECT stream, while a stream id names one data stream inside the session.
procedure TfrmServer.OnWTSession(Sender: TObject;
const aConnection: TsgcQUICServerConnection;
const aSession: TsgcWebTransportSession; var aAccept: Boolean);
begin
aAccept := True;
memoLog.Lines.Add('session accepted: id=' + IntToStr(aSession.SessionId) +
' from ' + aConnection.PeerIP + ':' + IntToStr(aConnection.PeerPort));
aSession.OnStream := OnWTStream;
end;