# `Cauldron2D.Beacon`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d/lib/cauldron_2d/beacon.ex#L1)

How a server on the local network is found: the host says so every two seconds on a
UDP port — `port/0`, the `:beacon_port` in the `:cauldron_2d` config, 2299 unless
set — to the broadcast address and to this machine, and whoever listens
(`Cauldron2D.Beacon.Listener`) hears it.

    {:ok, beacon} = Cauldron2D.Beacon.start_link(game: :my_game, host: "arcade", http: "http://192.168.1.5:2280", node: :"my_game@arcade")

A call is one line, `cauldron 1 <game> <host> <http url or -> <node or ->`. A node is
joined with its cookie, which the host shows and the caller types; it never goes over
the air.

# `call`

```elixir
@type call() :: %{
  game: String.t(),
  host: String.t(),
  http: String.t() | nil,
  node: atom() | nil
}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `line`

```elixir
@spec line(atom() | String.t(), String.t(), String.t() | nil, atom() | nil) ::
  String.t()
```

The line a host calls with.

# `parse`

```elixir
@spec parse(String.t()) :: {:ok, call()} | :error
```

A call heard, or `:error` for anything else.

# `port`

```elixir
@spec port() :: pos_integer()
```

The UDP port the calls go out on: `config :cauldron_2d, beacon_port: n`, else 2299.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Start calling; `:game` the game's name, `:host` the name to call as, `:http` the web URL or `nil`, `:node` the node name or `nil`, `:port` the UDP port (default `port/0`).

---

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