<PackageReference Include="System.Net.ServerSentEvents" Version="11.0.0-rc.1.26425.128" />

System.Net.ServerSentEvents.SseFormatter

public static class SseFormatter
Provides methods for formatting server-sent events.
public static Task WriteAsync(IAsyncEnumerable<SseItem<string>> source, Stream destination, CancellationToken cancellationToken = default)

Writes the source of server-sent events to the destination stream.

public static Task WriteAsync<T>(IAsyncEnumerable<SseItem<T>> source, Stream destination, Action<SseItem<T>, IBufferWriter<byte>> itemFormatter, CancellationToken cancellationToken = default)

Writes the source of server-sent events to the destination stream.