Cauldron2D.Net.Wire (Cauldron2D.Net v0.1.2)

Copy Markdown View Source

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)

Summary

Functions

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

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

A message to the server as a text frame.

A "frame" payload as the painter takes it.

A "map" payload as the painter takes it.

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.

Types

message()

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

Functions

decode(text)

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

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

decode_binary(arg1)

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

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

encode(join_ref, ref, topic, event, payload)

@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(payload)

@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(payload)

@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(payload)

@spec sheet(map()) :: %{
  tile: pos_integer(),
  columns: pos_integer(),
  frames: [{non_neg_integer(), non_neg_integer()}],
  anim: %{
    required(pos_integer()) => %{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.