Spell.Peer

The Spell.Peer module implements the general WAMP peer behaviour.

From the WAMP protocol:

A WAMP Session connects two Peers, a Client and a Router. Each WAMP Peer can implement one or more roles.

See new for documentation on starting new peers.

Source

Summary

add(options)

Add a new child as part of the supervision tree

await(peer, type, timeout \\ 1000)

Block until the process receives a message from peer of type or timeout

cast_role(peer, role, message)

Cast a message to a specific role

new(options)

Start a new peer with options. This function can be used to start a child outside of the supervision tree

send_message(peer, message)

Send a WAMP message from the peer

send_to_owner(peer, term)

Send an Erlang message to the peer’s owner

start_link()

Start Spell.Peer.Supervisor

stop(peer)

Stop the peer process

Types

start_option :: {:serializer, module} | {:transport, {module, Keyword.t}}

t :: %Spell.Peer{transport: %{}, serializer: %{}, owner: pid, role: %{}, retry_interval: integer, retries: integer, realm: term}

Functions

add(options)

Specs:

  • add(%{} | Keyword.t) :: {:ok, pid} | {:error, any}

Add a new child as part of the supervision tree.

Options

See new/1.

Source
await(peer, type, timeout \\ 1000)

Specs:

  • await(pid, atom, integer) :: {:ok, t} | {:error, timeout}

Block until the process receives a message from peer of type or timeout.

Source
cast_role(peer, role, message)

Specs:

  • cast_role(pid, module, any) :: :ok

Cast a message to a specific role.

Source
new(options)

Specs:

  • new(%{} | Keyword.t) :: {:ok, pid} | {:error, any}

Start a new peer with options. This function can be used to start a child outside of the supervision tree.

Options

  • :transport :: %{module: module, options: Keyword.t} required
  • :serializer :: %{module: module, options: Keyword.t} required
  • :realm :: Message.wamp_uri required
  • :roles :: [{module, Keyword.t}] required
  • :features :: map defaults to result of role’s get_features/1 callback
  • :owner :: pid defaults to self()
Source
send_message(peer, message)

Specs:

Send a WAMP message from the peer.

If a pid is provided as the peer, the message will be cast to and sent from the peer process. If it is the peer state, the message is sent directly.

Source
send_to_owner(peer, term)

Specs:

  • send_to_owner(pid, any) :: :ok

Send an Erlang message to the peer’s owner.

Source
start_link()

Start Spell.Peer.Supervisor.

Source
stop(peer)

Stop the peer process.

Source