WebSockex.Frame (WebSockex v0.4.3) View Source

Functions for parsing and encoding frames.

Link to this section Summary

Types

The incomplete or unhandled remainder of a binary

This is required to be valid UTF-8

Functions

Encodes a frame into a binary for sending.

Parses and combines two frames in a fragmented segment.

Parses a bitstring and returns a frame.

Link to this section Types

Specs

buffer() :: bitstring()

The incomplete or unhandled remainder of a binary

Specs

close_code() :: 1000..4999

Specs

frame() ::
  :ping
  | :pong
  | :close
  | {:ping, binary()}
  | {:pong, binary()}
  | {:close, close_code(), utf8()}
  | {:text, utf8()}
  | {:binary, binary()}
  | {:fragment, :text | :binary, binary()}
  | {:continuation, binary()}
  | {:finish, binary()}

Specs

opcode() :: :text | :binary | :close | :ping | :pong

Specs

utf8() :: binary()

This is required to be valid UTF-8

Link to this section Functions

Specs

encode_frame(frame()) ::
  {:ok, binary()}
  | {:error,
     %WebSockex.FrameEncodeError{
       __exception__: term(),
       close_code: term(),
       frame_payload: term(),
       frame_type: term(),
       reason: term()
     }}

Encodes a frame into a binary for sending.

Link to this function

parse_fragment(fragmented_parts, continuation_frame)

View Source

Specs

parse_fragment(
  {:fragment, :text | :binary, binary()},
  {:continuation | :finish, binary()}
) ::
  {:fragment, :text | :binary, binary()}
  | {:text | :binary, binary()}
  | {:error,
     %WebSockex.FragmentParseError{
       __exception__: term(),
       continuation: term(),
       fragment: term(),
       reason: term()
     }}

Parses and combines two frames in a fragmented segment.

Specs

parse_frame(bitstring()) ::
  :incomplete
  | {:ok, frame(), buffer()}
  | {:error,
     %WebSockex.FrameError{
       __exception__: term(),
       buffer: term(),
       opcode: term(),
       reason: term()
     }}

Parses a bitstring and returns a frame.