TsgcWebTransportSession › Properties › SessionId

SessionId Property

QUIC stream id of the Extended CONNECT request that established this WebTransport session.

Syntax

property SessionId: Int64 read FSessionId;

Type

Int64 (__int64 in C++Builder, long in C#).

Default

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.

Remarks

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 kindHeader written on the QUIC stream
Unidirectionalvarint(0x54) + varint(SessionId)
Bidirectionalvarint(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.

Example


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;

Back to Properties