Class SseEvent
- Namespace
- SseAssertions
- Assembly
- SseAssertions.dll
A single Server-Sent Events frame parsed from a stream. Matches the field set defined by the
WHATWG / W3C SSE specification: the event-name dispatched (event:), the buffered data
payload (data: lines joined by '\n'), the last-event-id (id:), and the
reconnection time the server suggests (retry:).
public sealed record SseEvent : IEquatable<SseEvent>
- Inheritance
-
SseEvent
- Implements
- Inherited Members
Remarks
The record is the stable public data type for the assertion family. SseFrameParser
parses a raw SSE body string into SseEvent instances and the fluent assertion
entry points (shipped in SseAssertions.TUnit) consume them.
EventName is non-nullable. A frame without an explicit event: field
dispatches as the SSE-default "message" per the WHATWG specification; the parser fills
in that default so consumers never have to reason about the missing-event-name case.
Constructors
SseEvent(string, string, string?, int?)
A single Server-Sent Events frame parsed from a stream. Matches the field set defined by the
WHATWG / W3C SSE specification: the event-name dispatched (event:), the buffered data
payload (data: lines joined by '\n'), the last-event-id (id:), and the
reconnection time the server suggests (retry:).
public SseEvent(string EventName, string Data, string? Id = null, int? RetryMillis = null)
Parameters
EventNamestringThe event type the frame dispatched. Equals the value of the
event:field when one was emitted, or the string"message"when noevent:field was present (the SSE-spec default).DatastringThe data payload, with multiple
data:lines joined by a single'\n'character. Never null; an empty string indicates a frame whosedata:field was empty or absent.IdstringThe last-event-id the server set via the
id:field, or null when no id was emitted.RetryMillisint?The reconnection time in milliseconds the server suggested via the
retry:field, or null when no retry was emitted or the value did not parse as a non-negative integer.
Remarks
The record is the stable public data type for the assertion family. SseFrameParser
parses a raw SSE body string into SseEvent instances and the fluent assertion
entry points (shipped in SseAssertions.TUnit) consume them.
EventName is non-nullable. A frame without an explicit event: field
dispatches as the SSE-default "message" per the WHATWG specification; the parser fills
in that default so consumers never have to reason about the missing-event-name case.
Properties
Data
The data payload, with multiple data: lines joined by a single
'\n' character. Never null; an empty string indicates a frame whose
data: field was empty or absent.
public string Data { get; init; }
Property Value
EventName
The event type the frame dispatched. Equals the value of the
event: field when one was emitted, or the string "message" when no event:
field was present (the SSE-spec default).
public string EventName { get; init; }
Property Value
Id
The last-event-id the server set via the id: field, or
null when no id was emitted.
public string? Id { get; init; }
Property Value
RetryMillis
The reconnection time in milliseconds the server suggested via the
retry: field, or null when no retry was emitted or the value did not
parse as a non-negative integer.
public int? RetryMillis { get; init; }
Property Value
- int?