sse v0.1.5 SSE.Chunk

Structure and type for Chunk model

Link to this section Summary

Types

t()

Defines the Chunk struct. Reference: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Fields

Link to this section Types

Link to this type t()
t() :: %SSE.Chunk{
  comment: binary(),
  data: [binary()],
  event: binary(),
  id: binary(),
  retry: integer()
}

Defines the Chunk struct. Reference: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Fields

  • :comment - The comment line can be used to prevent connections from timing out; a server can send a comment periodically to keep the connection alive. SSE package keeps connection alive, so you don’t have to send the comment.
  • :data - The data field for the message. When the EventSource receives multiple consecutive lines that begin with data:, it will concatenate them, inserting a newline character between each one. Trailing newlines are removed.
  • :event - A string identifying the type of event described. If this is specified, an event will be dispatched on the browser to the listener for the specified event name; the web site source code should use addEventListener() to listen for named events. The onmessage handler is called if no event name is specified for a message.
  • :id - The event ID to set the EventSource object’s last event ID value.
  • :retry - The reconnection time to use when attempting to send the event. This must be an integer, specifying the reconnection time in milliseconds. If a non-integer value is specified the field is ignored.

Link to this section Functions

Link to this function build(chunk)
build(SSE.Chunk.t()) :: String.t()