TsgcQUICClient › Methods › EnableMultiStream

EnableMultiStream Method

Switches the live connection into multi-stream mode so peer-opened streams are harvested and OnQUICStreamData fires.

Syntax

procedure EnableMultiStream;

Remarks

By default a QUIC client keeps a single default stream and has no read path at all. EnableMultiStream turns that around: it applies the OpenSSL incoming-stream accept policy to the connection and wires the stream-data callback, so that streams opened by the peer are harvested and every block of bytes read is reported through OnQUICStreamData. Calling it is a precondition for receiving anything, and for making OpenStream and WriteStreamData useful.

Call it after the connection has been established, for example inside the OnQUICConnect handler or straight after a successful Connect. It is silently ignored when there is no live connection, when SSLQUIC is False, or when the underlying UDP client has not been created yet, so calling it too early does nothing and reports no error.

The method works on both QUIC engines. On the builtin OpenSSL QUIC engine (qmBuiltin) it uses the OpenSSL stream API, and on the sgc engine (qmCustom) the streams are handled by the Pascal QUIC stack. See TsgcQUICClient for how the engine is selected.

This member is currently available in the Delphi/C++Builder implementation only. The .NET implementation opens exactly one bidirectional stream per connection and exposes no multi-stream API.

Example


oClient.OnQUICConnect := OnQUICConnectEvent;
oClient.OnQUICStreamData := OnQUICStreamDataEvent;
oClient.Connect;

procedure OnQUICConnectEvent(Sender: TObject; const Connection: TsgcQUICConnection);
var
  oStream: TsgcQUICClientStream;
begin
  TsgcQUICClient(Sender).EnableMultiStream;

  oStream := TsgcQUICClient(Sender).OpenStream;
  if Assigned(oStream) then
    TsgcQUICClient(Sender).WriteStreamData(oStream,
      TEncoding.UTF8.GetBytes('Hello QUIC'));
end;

Back to Methods