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

Chat rooms for a served game: one process, any number of rooms, the last messages kept.

    Cauldron2D.Drafter.Chat.ensure_started()
    Cauldron2D.Drafter.Chat.join(:lobby)
    Cauldron2D.Drafter.Chat.say(:lobby, "alice", "hello")

A process that joined a room receives `{:chat, room, %{from: name, text: text, at: ms}}`
for every message said in it, and stops receiving when it leaves or exits.
`history/1` is the last `100` messages, oldest first.

# `message`

```elixir
@type message() :: %{from: String.t(), text: String.t(), at: integer()}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `ensure_started`

```elixir
@spec ensure_started() :: :ok
```

Start the chat server registered under this module, or leave a running one be.

# `history`

```elixir
@spec history(term()) :: [message()]
```

The last messages in `room`, oldest first.

# `join`

```elixir
@spec join(term()) :: :ok
```

Receive `room`'s messages in the calling process.

# `leave`

```elixir
@spec leave(term()) :: :ok
```

Stop receiving `room`'s messages.

# `say`

```elixir
@spec say(term(), String.t(), String.t()) :: :ok
```

Say `text` in `room` as `from`.

---

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