SseKeepAliveSession Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before itβs released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Coordinates Server-Sent Events (SSE) writes to an output stream so that
long-running responses can periodically emit : keep-alive\n\n comment
frames without interleaving with application writes.
public sealed class SseKeepAliveSession : IAsyncDisposable
type SseKeepAliveSession = class
interface IAsyncDisposable
Public NotInheritable Class SseKeepAliveSession
Implements IAsyncDisposable
- Inheritance
-
SseKeepAliveSession
- Implements
Remarks
The session owns a synchronized write-only Stream (exposed via Stream) that callers should use in place of the underlying transport stream. All writes β both application data and the timer-driven keep-alive comments β acquire the same internal lock, guaranteeing that individual SSE frames are not split by a keep-alive emission.
Keep-alives are emitted only while a timer is active; pass InfiniteTimeSpan (or a non-positive TimeSpan) to Start(Stream, TimeSpan, ILogger, String) to obtain a session that only provides write synchronization. Use EnableKeepAlive(TimeSpan) to activate (or replace) the timer later β for example, from a content-type detection hook that fires before the first response byte.
Dispose the session before the response completes to stop the timer and release the internal lock.
Properties
| Name | Description |
|---|---|
| IsKeepAliveActive |
Gets a value indicating whether the keep-alive timer is currently active. |
| Stream |
Gets a write-only stream that serializes writes with the keep-alive timer. Callers should write application data through this stream instead of the underlying transport stream. |
Methods
| Name | Description |
|---|---|
| DisposeAsync() |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously. |
| EnableKeepAlive(TimeSpan) |
Activates (or replaces) the periodic keep-alive timer. A non-positive or
infinite |
| Start(Stream, TimeSpan, ILogger, String) |
Creates a session that wraps the specified |