ExPilot.Server (ExPilot v0.1.1)

Copy Markdown View Source

Serve ExPilot: its maps as arenas, over ssh and to browsers, through Cauldron2D.Drafter.Server.

ExPilot.Server.start(port: 2222, maps: ["priv/maps/dogfight.map.gz"])

Every map becomes an arena named after its file, its world starting on the first join and stopping again after a while with nobody in it. The same worlds are served to browsers by ExPilot.Web.Endpoint on the :http port. Players register on first connection as new@host, or on the web's login page; each account gets its own sound port, as Cauldron2D.Drafter.Server gives them. A started server names its VM and calls on the local network so other clients' connect screens list it.

Options

  • :port — the ssh port. Default 2222
  • :ip — what to bind, as Drafter.Server.start_ssh/2 takes it. Default :any
  • :accounts — the account file. Default $XDG_DATA_HOME/expilot/accounts.terms, taking over an ex_pilot_accounts.bin in the working directory left by an older server
  • :maps — map files to offer. Default: every file under priv/maps
  • :system_dir — the ssh host key directory. Default: drafter's temporary keys
  • :robots — robots per arena. Default: each map's maxrobots
  • :http — the port of the web pages, on every IPv4 interface; false or 0 for none. Default: PORT in the environment, else 2280
  • :beacon, :beacon_port — as Cauldron2D.Drafter.Server takes them
  • :music, :sfx — the browsers' and desktops' sound, as Cauldron2D.Net.Audio.set/1 takes them: music :personal (default), :arena, :dynamic, :static or :off; effects :personal (default) or :off. With :static the songs of ExPilot.Music.Static are rendered at 44 100 Hz stereo as the server starts, in the background, unless they are on disk from before, under $XDG_CACHE_HOME/expilot/music

Summary

Functions

The default account file, $XDG_DATA_HOME/expilot/accounts.terms (~/.local/share without the variable). When it does not exist and legacy does — an ex_pilot_accounts.bin in the working directory from an older server — its accounts are read and written there as text first.

The map files shipped with the package.

The web port when none is given: PORT in the environment, else 2280.

This machine's name, as players are told to connect to it.

Register the arenas and start serving; see the module documentation for the options.

Stop what start/1 started, and the arenas' worlds; the arenas stay registered for the next start.

Types

t()

@type t() :: %{
  :arenas => [atom()],
  :daemon => term(),
  :accounts => pid(),
  :http => pos_integer() | nil,
  optional(:node) => node() | nil,
  optional(:beacon) => pid() | nil,
  optional(:web) => module() | nil
}

Functions

accounts_path(legacy \\ "ex_pilot_accounts.bin")

@spec accounts_path(Path.t()) :: Path.t()

The default account file, $XDG_DATA_HOME/expilot/accounts.terms (~/.local/share without the variable). When it does not exist and legacy does — an ex_pilot_accounts.bin in the working directory from an older server — its accounts are read and written there as text first.

bundled_maps()

@spec bundled_maps() :: [Path.t()]

The map files shipped with the package.

default_http()

@spec default_http() :: pos_integer()

The web port when none is given: PORT in the environment, else 2280.

hostname()

@spec hostname() :: String.t()

This machine's name, as players are told to connect to it.

start(opts \\ [])

@spec start(keyword()) :: {:ok, t()} | {:error, term()}

Register the arenas and start serving; see the module documentation for the options.

stop(server)

@spec stop(t()) :: :ok

Stop what start/1 started, and the arenas' worlds; the arenas stay registered for the next start.