View Source ServerSentEvents (Server Sent Events v0.2.1)
This module implements a parser for Server Sent Events. See the official specification for details on parsing and interpreting the event stream.
Summary
Functions
Parses a chunk of data into a list of Server Sent Event messages.
Functions
Parses a chunk of data into a list of Server Sent Event messages.
Returns a tuple containing the list of parsed events and the remaining data from the chunk if it contained an incomplete event.
There are only four possible keys in the event map: :id
, :event
, :data
, :retry
.
Examples
iex> ServerSentEvents.parse("event: event\ndata: {\"complete\":")
{[], "event: event\ndata: {\"complete\":"}
iex> ServerSentEvents.parse("event: event\ndata: {\"complete\":true}\n\n")
{[%{event: "event", data: "{\"complete\":true}"}], ""}