# `Cauldron2D.Net.Wire`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d_net/lib/cauldron_2d/net/wire.ex#L1)

The Phoenix channel protocol (serializer 2.0.0) as an Elixir client speaks it, and
the `cauldron_2d_net` messages read into plain shapes: a frame's focus, movers as
`{index, x, y}`, hud rows of `{text, colour}` runs and the outcome; a map's rows of
indices; a sheet's tile, frames, URL and void colour. What a desktop view, a terminal
or any other program joining a served world over its WebSocket draws from.

    Cauldron2D.Net.Wire.encode(join_ref, ref, topic, "phx_join", params)
    Cauldron2D.Net.Wire.decode(text)
    Cauldron2D.Net.Wire.decode_binary(bytes)

# `message`

```elixir
@type message() ::
  {:reply, String.t(), String.t(), String.t(), String.t(), map()}
  | {:push, String.t() | nil, String.t(), String.t(), term()}
  | :other
```

# `decode`

```elixir
@spec decode(String.t()) :: message()
```

A text frame from the server: a reply to one of ours, or a push.

# `decode_binary`

```elixir
@spec decode_binary(binary()) :: message()
```

A binary frame from the server: a push or a broadcast with raw bytes.

# `encode`

```elixir
@spec encode(String.t() | nil, String.t() | nil, String.t(), String.t(), map()) ::
  String.t()
```

A message to the server as a text frame.

# `frame`

```elixir
@spec frame(map()) :: %{
  focus: {float(), float()},
  movers: [{non_neg_integer(), float(), float()}],
  labels: [{String.t(), float(), float(), String.t() | nil, pos_integer()}],
  hud: [[{String.t(), String.t() | nil}]],
  over: map() | nil,
  subject: term()
}
```

A `"frame"` payload as the painter takes it.

# `map`

```elixir
@spec map(map()) :: %{
  width: pos_integer(),
  height: pos_integer(),
  tile: pos_integer(),
  wrap: boolean(),
  rows: [[non_neg_integer()]]
}
```

A `"map"` payload as the painter takes it.

# `sheet`

```elixir
@spec sheet(map()) :: %{
  tile: pos_integer(),
  columns: pos_integer(),
  frames: [{non_neg_integer(), non_neg_integer()}],
  anim: %{
    required(pos_integer()) =&gt; %{indices: [pos_integer()], fps: pos_integer()}
  },
  url: String.t(),
  void: {byte(), byte(), byte()}
}
```

A `"sheet"` payload: the tile size, the columns, where each index sits, the animations by first index, the void colour and the PNG's url.

---

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