Class ServerSentEventsResult<T>
Writes a handler's events as text/event-stream: each event's name is its
EventType, its id the item's, and its data the JSON of the event
serialized as the union (so the type discriminator is always written). The stream ends
quietly when the client disconnects or the app stops, so open streams never hold up shutdown.
public sealed class ServerSentEventsResult<T> : IResult where T : IServerSentEvent
Type Parameters
T
- Inheritance
-
ServerSentEventsResult<T>
- Implements
- Inherited Members
Constructors
ServerSentEventsResult(IAsyncEnumerable<ServerSentEvent<T>>)
Writes a handler's events as text/event-stream: each event's name is its
EventType, its id the item's, and its data the JSON of the event
serialized as the union (so the type discriminator is always written). The stream ends
quietly when the client disconnects or the app stops, so open streams never hold up shutdown.
public ServerSentEventsResult(IAsyncEnumerable<ServerSentEvent<T>> events)
Parameters
eventsIAsyncEnumerable<ServerSentEvent<T>>
Methods
ExecuteAsync(HttpContext)
Write an HTTP response reflecting the result.
public Task ExecuteAsync(HttpContext httpContext)
Parameters
httpContextHttpContextThe HttpContext for the current request.
Returns
- Task
A task that represents the asynchronous execute operation.