lobby v0.0.1 Lobby

This module defines the GenServer that is the lobby GenServer The lobby’s sole purpose is to manage members, their ids, and thei current state.

Link to this section Summary

Functions

Returns the state for the given member id

Returns the map that represents the entire lobby

Creates and returns a new member id and state

Removes the memmber for the given member_id from the lobby

Starts and returns a Lobby GenServer process First argument is the name you want to give the lobby, if any

Updates the member for the given id

Link to this section Functions

Link to this function get_member(lobby, member_id)
get_member(pid | atom, number) ::
  {:ok, map} |
  {:error, String.t}

Returns the state for the given member id

Example

iex> Lobby.get_member(:test_lobby, 0)
{:ok, %{}}
Link to this function lobby(lobby)
lobby(pid | atom) :: {:ok, map}

Returns the map that represents the entire lobby

Examples

iex> Lobby.lobby(:test_lobby)
{:ok, %{0 => %{}}}
Link to this function new_member(lobby)
new_member(pid | atom) ::
  {:ok, {number, map}} |
  {:error, String.t}

Creates and returns a new member id and state

Example

iex> Lobby.new_member(:test_lobby)
{:ok, {1, %{}}}
Link to this function remove_member(lobby, member_id)
remove_member(pid | atom, number) :: :ok

Removes the memmber for the given member_id from the lobby

Example

iex> Lobby.remove_member(:test_lobby, 0)
iex> Lobby.get_member(:test_lobby, 0)
{:error, "No member for id"}
Link to this function start_link(name \\ nil)
start_link(atom) :: {:ok, pid} | {:error, String.t}

Starts and returns a Lobby GenServer process First argument is the name you want to give the lobby, if any.

Link to this function update_member(lobby, member_id, member)
update_member(pid | atom, number, map) :: :ok

Updates the member for the given id

Example

iex> Lobby.update_member(:test_lobby, 0, %{sweet: :state})
iex> Lobby.get_member(:test_lobby, 0)
{:ok, %{sweet: :state}}