<PackageReference Include="System.ClientModel" Version="1.1.0-beta.6" />

ServerSentEventReader

sealed class ServerSentEventReader
An SSE event reader that reads lines from an SSE stream and composes them into SSE events. See SSE specification: https://html.spec.whatwg.org/multipage/server-sent-events.html
public string LastEventId { get; }

public ServerSentEvent? TryGetNextEvent(CancellationToken cancellationToken = default)

Synchronously retrieves the next server-sent event from the underlying stream, blocking until a new event is available and returning null once no further data is present on the stream.

public Task<ServerSentEvent?> TryGetNextEventAsync(CancellationToken cancellationToken = default)

Asynchronously retrieves the next server-sent event from the underlying stream, blocking until a new event is available and returning null once no further data is present on the stream.