View Source Barytherium.Frame (barytherium v0.2.0)

Representation of a STOMP frame.

In STOMP, each frame has three components:

  • command (1, mandatory) - only specified commands are permitted
  • headers (0 or more, see below) - unspecified headers permitted
  • body (empty for commands other than SEND, MESSAGE and ERROR)

Most commands have required and optional headers, and non-specified headers can also be given (though these have no specified semantics, of course). Most headers aren't relevant to frame parsing, with the exception of content-length, which defines the length of a frame's body.

It's legal for header keys to be duplicated. In this case, only the first takes effect.

Supported client frames:

  • :connect (CONNECT)
  • :disconnect (DISCONNECT)
  • :ack (ACK)
  • :nack (NACK)
  • :begin (BEGIN)
  • :commit (COMMIT)
  • :abort (ABORT)
  • :send (SEND)
  • :subscribe (SUBSCRIBE)
  • :unsubscribe (UNSUBSCRIBE)

Supported server frames:

  • :connected (CONNECTED)
  • :error (ERROR)
  • :message (MESSAGE)
  • :receipt (RECEIPT)

Specification section: https://stomp.github.io/stomp-specification-1.2.html#STOMP_Frames

Link to this section Summary

Link to this section Types

@type frame_body() :: binary()
@type frame_command() ::
  :connect
  | :disconnect
  | :ack
  | :nack
  | :begin
  | :commit
  | :abort
  | :send
  | :subscribe
  | :unsubscribe
  | :connected
  | :error
  | :message
  | :receipt
@type frame_headers() :: [{binary(), binary()}]
@type parse_state() ::
  {:command, nil, integer(), nil, binary()}
  | {:headers | :body, t(), integer(), integer() | nil, binary()}
@type parse_state_return() ::
  parse_state() | {:done, t(), nil, 0, binary()} | {:error, atom(), binary()}
@type t() :: %Barytherium.Frame{
  body: frame_body(),
  command: frame_command(),
  headers: frame_headers()
}

Link to this section Functions

@spec format([t()]) :: binary()
@spec headers_to_map(frame_headers()) :: map()
@spec parse(parse_state()) :: parse_state_return()
@spec parse_all(parse_state()) :: {parse_state_return(), [t()]}