API Reference Cauldron2D.Net v#0.1.2

Copy Markdown View Source

Modules

A cauldron_2d world in a browser, and the links an Elixir client uses to join a served world.

What a client on another machine asks a server over plain HTTP, as a plug a game forwards a path to: a token for a name and password (POST /token, with register: true to make the account first), the arenas (GET /arenas) as a lobby lists them, how the server is keeping up (GET /stats), and the boards (GET /leaders?period=day| week|all&metric=<name>&arena=<name>) when the game keeps a ledger.

The server's sound policy: what every session's sound costs it.

Sets the sessions' rate from the node's load under :dynamic music: every five seconds it reads how busy the schedulers were, drops the rate to 22 050 Hz once they pass 60%, and brings it back to the policy's once they fall under 30%, holding each for thirty seconds at least. Under any other music policy it leaves the rate alone.

One world's music, synthesised once for every session in it: a Cauldron2D.Audio cued from the world's own state, its PCM sent to every subscriber as {:cauldron_shared_pcm, chunk}.

The Phoenix channel a game's browser players join, one per player, driven by Cauldron2D.Net.Session.

What goes over the wire to a browser: the static map once, and a frame per tick, with arts as sheet indices.

A game's keymap as a browser reads it: Cauldron2D.Input key specs become KeyboardEvent.code names, and mouse buttons the button numbers cauldron.js takes.

A player's connection to a world reachable as a process — on this node, or on a node this one is connected to — through Cauldron2D.Net.Session, so the frames arrive in the same shape a Cauldron2D.Net.Link.Socket delivers.

A player's connection to a game server anywhere: the same Phoenix channel a browser uses, over a WebSocket, speaking Cauldron2D.Net.Wire.

A server's arena spoken for in this VM: a process a client joins, sends input to and leaves exactly as it would a Cauldron2D.World (Cauldron2D.Player), which opens a WebSocket to the server for each player (Cauldron2D.Net.Link.Socket) and turns what comes back into frames, and plays the sound that comes with them through this machine's speaker.

A load test against a running server: players and watchers joining its arenas over the wire, the frames they get measured against the steps the server runs, and the server's own numbers (Cauldron2D.Net.Api's /stats) alongside.

One session of a load test: a player or a watcher on a server's arena over the same WebSocket a browser or the desktop uses (Cauldron2D.Net.Link.Socket), counting the frames it gets. A player changes what it holds five times a second, at random from the actions it was given.

The pages around a game's worlds in a browser: a title, a lobby of arenas, the arena, settings and the guide, from a Cauldron2D.Client.Game, as a plug a game forwards a path to.

What a client asks a server it does not run in: a token for a name and password over HTTP (Cauldron2D.Net.Api), the arenas, the server's stats and boards; and the same from a node it is connected to.

Names for worlds that are not in this VM, so a client joins them as it joins any Cauldron2D.World: {:via, Cauldron2D.Net.Remote.Worlds, name}.

A browser player's life in a world, as functions over a struct, for a channel process to drive: the process calling join/4 becomes the world's player and gets its frames and its audio's PCM as messages.

A Cauldron2D.Atlas as one PNG sprite sheet and an index a browser draws from, packed by Cauldron2D.Sheet.

The player socket a game's browser players connect through, with the channel Cauldron2D.Net.Channel defines.

Plays the PCM a Cauldron2D.Net.Link.Socket delivers through this machine's speaker, in a process of its own so the writes never hold up whoever draws.

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.