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.
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 |
| call(peer, role, message) | Synchronously send a message to the role |
| new(options) | Start a new peer with |
| notify(pid, term) | |
| 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 |
| stop(peer) | Stop the |
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
Specs:
- add(%{} | Keyword.t) :: {:ok, pid} | {:error, any}
Add a new child as part of the supervision tree.
Options
See new/1.
Specs:
- await(pid, atom, integer) :: {:ok, t} | {:error, timeout}
Block until the process receives a message from peer of type or timeout.
Specs:
- call(pid, module, any) :: :ok
Synchronously send a message to the role.
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_urirequired:roles :: [{module, Keyword.t}]required:features :: mapdefaults to result of role’sget_features/1callback:owner :: piddefaults to self()
Specs:
- notify(pid, any) :: :ok
Specs:
- send_message(pid | t, Spell.Message.t) :: :ok | {:error, any}
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.
Specs:
- send_to_owner(pid, any) :: :ok
Send an Erlang message to the peer’s owner.
TODO: Rename to notify
Start Spell.Peer.Supervisor.
Stop the peer process.