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 theload/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
board()
Specs
board() :: any()
Link to this section Functions
Options
Board
:load_mode
– Allowed values are:sync
and:async
. Sets wether theload/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 generatedSupervisor
module that will supervise other components (such as registry, servers supervisor). Defaults to__MODULE__.Supervisor
.:registry
– The registration name for theRegistry
ofMogs.Board.Server
processes handling boards. Defaults to__MODULE__.Server.Registry
.:server_sup
– The name for the generatedDynamicSupervisor
module that will supervise eachMogs.Board.Server
server process. Defaults to__MODULE__.Server.DynamicSupervisor
.:tracker
– Options for the tracker: Keep unset or passnil
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
add_player(name_or_pid, player_id, data, pid)
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.
read_state(name_or_pid, fun)
remove_player(name_or_pid, player_id, reason, clear_tracking?)
send_command(name_or_pid, command)
start_server(module, supervisor, id, opts)
track_player(name_or_pid, player_id, pid)
Link to this section Callbacks
handle_add_player(board, player_id, data)
Specs
handle_command(command, board)
Specs
handle_command(command :: any(), board :: any()) :: Mogs.Board.Command.Result.t()
handle_error(reason, board)
Specs
handle_remove_player(board, player_id, reason)
Specs
handle_timer(command, board)
Specs
handle_timer(command :: any(), board :: any()) :: Mogs.Board.Command.Result.t()