Struct uhttp_sse::SseMessage [] [src]

pub struct SseMessage<W: Write>(_);

An SSE message.

Each message consists of any number of fields followed by a message terminating sequence. The member functions allow "appending" a field to the message any number of times, and when the SseMessage goes out of scope, the message is flushed and terminated.

Methods

impl<W: Write> SseMessage<W>
[src]

Create a new SseMessage to write into the given stream.

Append a data field.

This is the data payload passed into the browser event listener callback when the message is terminated. It can be raw text, JSON, or any other format. If a message contains multiple data fields, the browser concatenates their values until the end of the message.

This field is the only "required" one, in that a message with an empty data field won't trigger any event listener in the browser.

Append an event name field.

This optional field tags the current message with an event name, which causes the browser to trigger an event listener specifically for that event.

Append an event ID field.

This optional field sets the "last event ID" of the current event stream.

Append a retry field.

This optional field must be an integer and sets the reconnection time of the current event stream, which is the millisecond delay used when the browser attempts to reestablish a connection to the stream.

Terminate the current message and begin a new one.

Trait Implementations

impl<W: Write> Drop for SseMessage<W>
[src]

Writes the message terminating sequence and flushes on drop.

A method called when the value goes out of scope. Read more