Spell.Role.Session

The Spell.Role.Session module implements the behaviour for a session role.

Sessions are pseudo-roles; each peer started with Spell.Connect has Spell.Role.Session added as the first role in roles.

Source

Summary

await_welcome(peer)

Await the welcome message. Useful for blocking until the session is established

call_goodbye(peer, options \\ [])

Send a GOODBYE message to the remote peer and wait for the GOODBYE reply

cast_goodbye(peer, options \\ [])

Send a GOODBYE message to the remote peer. The remote peer should reply with a GOODBYE

get_features(options)

Callback implementation for Spell.Role.get_features/1

handle_cast(, , state)

Callback implementation for Spell.Role.handle_cast/3

handle_message(welcome, peer, state)

Handle WELCOME, GOODBYE, and ABORT messages

init(peer_options, options)

Returns the state with the specified realm and role

on_close(peer, state)

Callback implementation for Spell.Role.on_close/2

on_open(peer, state)

Send a HELLO message when the connection is opened

Functions

await_welcome(peer)

Specs:

Await the welcome message. Useful for blocking until the session is established.

Source
call_goodbye(peer, options \\ [])

Specs:

Send a GOODBYE message to the remote peer and wait for the GOODBYE reply.

This must be called from the peer’s owner, otherwise the listening process won’t receive the GOODBYE message.

Source
cast_goodbye(peer, options \\ [])

Specs:

Send a GOODBYE message to the remote peer. The remote peer should reply with a GOODBYE.

Source
get_features(options)

Callback implementation for Spell.Role.get_features/1.

Source
handle_cast(, , state)

Callback implementation for Spell.Role.handle_cast/3.

Source
handle_message(welcome, peer, state)

Handle WELCOME, GOODBYE, and ABORT messages.

Behaviour

  • WELCOME: set the peer session
  • GOODBYE: close the connection normally
  • ABORT: close the connection with an error. With the default supervision settings, the peer will be restarted.
Source
init(peer_options, options)

Returns the state with the specified realm and role.

  • peer_options :: Map.t
Source
on_close(peer, state)

Callback implementation for Spell.Role.on_close/2.

Source
on_open(peer, state)

Send a HELLO message when the connection is opened.

Source