mogs v0.2.0 Mogs.Board behaviour
Link to this section Summary
Functions
Options
Board
:load_mode– Allowed values are:syncand:async. Sets wether theload/2callback 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:syncand:async. Sets wether theload/2callback 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 generatedSupervisormodule that will supervise other components (such as registry, servers supervisor). Defaults to__MODULE__.Supervisor.:registry– The registration name for theRegistryofMogs.Board.Serverprocesses handling boards. Defaults to__MODULE__.Server.Registry.:server_sup– The name for the generatedDynamicSupervisormodule that will supervise eachMogs.Board.Serverserver process. Defaults to__MODULE__.Server.DynamicSupervisor.:tracker– Options for the tracker: Keep unset or passnilto 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/3is 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()