# `Cauldron2D.Drafter.Server`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d_drafter/lib/cauldron_2d/drafter/server.ex#L1)

Serve a game over ssh, with its accounts, its web endpoint and its beacon.

    {:ok, server} = Cauldron2D.Drafter.Server.start(game: MyGame.Client, port: 2222, web: {:my_game, MyGame.Web.Endpoint, 2280})
    Cauldron2D.Drafter.Server.stop(server)

Players register on first connection as `new@host` (`:register_as`), or through
whatever login the game's web pages offer. Each account is given its own sound
port on the server — `:sound_port` for the first account, the next number for the
next, and so on — kept in its props as `:pulse_port`; the terminal client's audio
goes as raw PCM through the `ssh -R <port>:127.0.0.1:4713` tunnel to a player
program on the player's machine. The arenas are the game's, registered with
`Cauldron2D.Arenas` before or after the server starts.

## Options

  * `:game` — the module implementing `Cauldron2D.Client.Game`. Required
  * `:port` — the ssh port. Default `2222`
  * `:ip` — what to bind, as `Drafter.Server.start_ssh/2` takes it. Default `:any`
  * `:accounts` — the account file, or a running `Drafter.Accounts` server. Default
    `Cauldron2D.Paths.data(atlas, "accounts.terms")`
  * `:accounts_name` — a name for the accounts server it starts. Default none
  * `:sound_port` — the first account's sound port, `false` for none. Default `24713`
  * `:system_dir` — the ssh host key directory. Default: drafter's temporary keys
  * `:register_as` — the name that registers. Default `"new"`
  * `:mount_props` — merged into every session's mount props. Default `%{}`
  * `:web` — `{otp_app, endpoint, port}`: the game's Phoenix endpoint, started on
    every IPv4 interface at that port. Default: none
  * `:beacon` — call on the local network with `Cauldron2D.Beacon`. Default `true`
  * `:beacon_port` — its port. Default `Cauldron2D.Beacon.port/0`
  * `:node` — name this VM so other nodes can join its worlds, `false` for none.
    Default `<atlas>@<host>`, when the VM is not already named

Returns `{:ok, %{daemon, accounts, http, node, beacon}}`; `stop/1` stops what was
started, leaving the arenas registered.

# `t`

```elixir
@type t() :: %{
  daemon: pid() | [pid()],
  accounts: pid(),
  http: pos_integer() | nil,
  node: node() | nil,
  beacon: pid() | nil,
  web: module() | nil
}
```

# `hostname`

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

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

# `start`

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

Start serving; see the module documentation for the options.

# `stop`

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

Stop what `start/1` started.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
