mogs v0.2.0 Mogs.Board behaviour

Link to this section Summary

Functions

Options

Board

  • :load_mode – Allowed values are :sync and :async. Sets wether the load/2 callback will be called during the board server initialization (:sync) or after initialization. Defaults to :sync.

Services

Those options allow to define the generated modules or services associated to a board module. If a module would be generated, the option sets both the module name and the process registration name.

Validates a Mogs.Board option. raise if the option is not valid or is unknown. Returns the option value or a default value if the option supports it.

Link to this section Types

Specs

board() :: any()

Link to this section Functions

Link to this macro

__using__(opts)

(macro)

Options

Board

  • :load_mode – Allowed values are :sync and :async. Sets wether the load/2 callback will be called during the board server initialization (:sync) or after initialization. Defaults to :sync.

Services

Those options allow to define the generated modules or services associated to a board module. If a module would be generated, the option sets both the module name and the process registration name.

Setting an option to false or nil will disable the corresponding feature and no module will be generated during compilation and/or no process will be started nor registered during runtime.

  • :supervisor – The name for a generated Supervisor module that will supervise other components (such as registry, servers supervisor). Defaults to __MODULE__.Supervisor.
  • :registry – The registration name for the Registry of Mogs.Board.Server processes handling boards. Defaults to __MODULE__.Server.Registry.
  • :server_sup – The name for the generated DynamicSupervisor module that will supervise each Mogs.Board.Server server process. Defaults to __MODULE__.Server.DynamicSupervisor.
  • :tracker – Options for the tracker: Keep unset or pass nil to disable player tracking. Currently only one option is supported:

    • :timeout – Time in milliseconds before considering an user has left the game, i.e. where the user has no tracked process alive. handle_remove_player/3 is called after the timeout
Link to this function

add_player(name_or_pid, player_id, data, pid)

Link to this function

check_opt(opts, key, default \\ nil)

Validates a Mogs.Board option. raise if the option is not valid or is unknown. Returns the option value or a default value if the option supports it.

This function is intended to be called at compile time.

Link to this function

read_state(name_or_pid, fun)

Link to this function

remove_player(name_or_pid, player_id, reason, clear_tracking?)

Link to this function

send_command(name_or_pid, command)

Link to this function

start_server(module, supervisor, id, opts)

Link to this function

track_player(name_or_pid, player_id, pid)

Link to this section Callbacks

Link to this callback

handle_add_player(board, player_id, data)

Specs

handle_add_player(board :: any(), player_id :: any(), data :: any()) ::
  {:ok, board :: any()} | {:error, reason :: any()}
Link to this callback

handle_command(command, board)

Specs

handle_command(command :: any(), board :: any()) ::
  Mogs.Board.Command.Result.t()
Link to this callback

handle_error(reason, board)

Specs

handle_error(reason :: any(), board :: any()) ::
  {:ok, board :: any()} | {:stop, reason :: any()}
Link to this callback

handle_remove_player(board, player_id, reason)

Specs

handle_remove_player(board :: any(), player_id :: any(), reason :: any()) ::
  {:ok, board :: any()} | {:stop, reason :: any()}
Link to this callback

handle_timer(command, board)

Specs

handle_timer(command :: any(), board :: any()) :: Mogs.Board.Command.Result.t()
Link to this callback

handle_update(board)

Specs

handle_update(board :: any()) ::
  {:ok, board :: any()} | {:stop, reason :: any()}
Link to this callback

load(id, load_info)

Specs

load(id :: any(), load_info :: any()) ::
  {:ok, board :: any()} | {:error, reason :: any()}