ServerSentEventStage.Event (ServerSentEventStage v1.2.0) View Source

A single ServerSentEvent (SSE) from a server.

The SSE protocol is defined by the W3C.

Link to this section Summary

Functions

Parse a UTF-8 string into a struct.

Link to this section Types

Specs

t() :: %ServerSentEventStage.Event{data: String.t(), event: String.t()}

Link to this section Functions

Parse a UTF-8 string into a struct.

Expects a full SSE block.

iex> from_string("event: put\rdata:123\r\ndata: 456\n")
%Event{event: "put", data: "123\n456\n"}

iex> from_string(":comment\ndata:  short\nignored: field")
%Event{event: "message", data: " short\n"}