flux v0.1.1 Flux.Websocket.Frame

Convenience functions for building websocket frames.

Link to this section Summary

Types

Atom representations of the various opcodes that are available when building a websocket frame

t()

A parsed frame recieved from a client

Functions

Builds a server websocket frame with the given opcode and payload. Supports binaries and iodata as payloads. Because this is a server frame, it does NOT mask the payload

Gives the integer that an opcode atom represents For example:

iex(1)> opcode_from_atom(:text)
1

Gives the corresponding atomic representation of an opcode For example:

iex(1)> opcode_to_atom(1)
:text

Link to this section Types

Link to this type opcode()
opcode() :: :continue | :text | :binary | :close | :ping | :pong

Atom representations of the various opcodes that are available when building a websocket frame.

Link to this type t()
t() :: %Flux.Websocket.Frame{
  close_code: pos_integer() | nil,
  fin: boolean(),
  mask: integer(),
  mask?: boolean(),
  opcode: atom(),
  payload: binary() | iodata(),
  payload_length: non_neg_integer(),
  reserved: map()
}

A parsed frame recieved from a client.

Link to this section Functions

Link to this function build_frame(type, payload)
build_frame(opcode(), iodata() | binary()) :: iodata()

Builds a server websocket frame with the given opcode and payload. Supports binaries and iodata as payloads. Because this is a server frame, it does NOT mask the payload.

Link to this function opcode_from_atom(arg1)
opcode_from_atom(opcode()) :: non_neg_integer()

Gives the integer that an opcode atom represents For example:

iex(1)> opcode_from_atom(:text)
1
Link to this function opcode_to_atom(code)
opcode_to_atom(non_neg_integer()) :: opcode()

Gives the corresponding atomic representation of an opcode For example:

iex(1)> opcode_to_atom(1)
:text