asobi_match_server (asobi v0.35.4)

View Source

Per-match gen_statem driving the configured game module.

Trust boundary (F-32): asobi is single-tenant by design. The configured game module (Mod:join/2, Mod:tick/1, Mod:handle_input/3, phase / vote callbacks, etc.) is trusted code. We do not wrap callbacks in try/catch — a crash in the game module is treated as a bug worth surfacing, not a security boundary to harden against. The match supervisor restarts the match server up to 10 times in 60s (transient + intensity 10) before the entire asobi_match_sup falls over, intentionally taking the lobby with it so an obviously broken game cannot keep churning silently.

In multi-tenant or sandboxed contexts (asobi_lua) callbacks are run through a Lua sandbox that has its own fault-isolation; that wrapper is the place to put callback hardening.

Summary

Functions

broadcast_event(Pid, Event, Payload)

-spec broadcast_event(pid(), atom() | binary(), map()) -> ok.

callback_mode()

-spec callback_mode() -> gen_statem:callback_mode_result().

cancel(Pid)

-spec cancel(pid()) -> ok.

cast_vote(Pid, PlayerId, VoteId, OptionId)

-spec cast_vote(pid(), binary(), binary(), binary()) -> ok | {error, term()}.

finished/3

-spec finished(gen_statem:event_type() | enter, term(), map()) -> gen_statem:state_enter_result(atom()).

get_info(Pid)

-spec get_info(pid()) -> map().

handle_input(Pid, PlayerId, Input)

-spec handle_input(pid(), binary(), map()) -> ok.

init(Config)

-spec init(map()) -> {ok, atom(), map()}.

join(Pid, PlayerId)

-spec join(pid(), binary()) -> ok | {error, term()}.

leave(Pid, PlayerId)

-spec leave(pid(), binary()) -> ok.

pause(Pid)

-spec pause(pid()) -> ok | {error, term()}.

paused/3

-spec paused(gen_statem:event_type() | enter, term(), map()) -> gen_statem:state_enter_result(atom()).

reconnect(Pid, PlayerId)

-spec reconnect(pid(), binary()) -> ok | {error, term()}.

resume(Pid)

-spec resume(pid()) -> ok | {error, term()}.

running/3

-spec running(gen_statem:event_type() | enter, term(), map()) -> gen_statem:state_enter_result(atom()).

start_link(Config)

-spec start_link(map()) -> gen_statem:start_ret().

start_vote(Pid, VoteConfig)

-spec start_vote(pid(), map()) -> {ok, pid()} | {error, term()}.

terminate/3

-spec terminate(term(), atom(), map()) -> ok.

use_veto(Pid, PlayerId, VoteId)

-spec use_veto(pid(), binary(), binary()) -> ok | {error, term()}.

waiting/3

-spec waiting(gen_statem:event_type() | enter, term(), map()) -> gen_statem:state_enter_result(atom()).

whereis(MatchId)

-spec whereis(binary()) -> {ok, pid()} | error.