Skip to main content

Module link

Module link 

Source
Expand description

The live link (ADR-0047): how a tool reaches a build that is already running, in a debug build with the backend’s link feature. The wire is JSON lines, one UTF-8 JSON object per line: the client sends a Request per line, and the build answers each with an Answer, in order. The first line must be a Request::Hello with the build’s token, or the connection is closed.

This module touches no device. A backend carries the lines (TCP on loopback in shuyi-app) and the Server turns each into its answer over the App it runs: it reads the screens, the frame as text, the window’s picture (taken by the backend), the log, and the frames’ records with a heap snapshot (taken by the backend), and its only input is raw device events the backend adds after the devices’ own in Platform::poll_input, so they go where a player’s go. It changes nothing any other way.

shuyi attach is the client, and shares these types with the build, so the two ends can’t drift; VERSION says which wire they speak.

Modules§

base64
Base64 (RFC 4648 §4, the standard alphabet, with padding): how the link carries a picture in a JSON line, and how MCP carries an image.

Structs§

LogAnswer
The log’s lines a Request::Log asked for.
LogEntry
One line of the log, with its number in the ring.
PerfAnswer
The frames’ records a Request::Perf asked for, counted as the contract’s PerfRead counts them.
Played
What a Request::Play did.
Screenshot
The window’s picture.
Server
The build’s end of the link, for one client: it turns the client’s lines into answers over the App the backend runs, and gives the backend a play’s input frame by frame. The backend makes one per connection.
Status
Where a running build is.

Enums§

Answer
A line the build sends, tagged by answer.
Handled
What the Server made of a line.
Phase
Which part of its life the game is in.
Request
A line a client sends, tagged by op.

Constants§

MAX_LINE
The longest request line, in bytes: a longer one closes the link.
MAX_UNSENT
The most bytes of answers a client may leave unread: past it, the backend drops the client.
MAX_WAIT
The longest Step::Wait of a play, in seconds: half an hour, played as the build’s frames at 60 a second (script::wait_frames).
PERF_MAX
How many records a Request::Perf answers when it doesn’t say.
VERSION
The link’s version: a client and a build speak the same, or the build closes the link after its hello.

Functions§

check_play
Whether a play’s steps can be played: each step (Step::check), waits of at most MAX_WAIT seconds, and no crank or debug step; an error names the step. An action’s name is looked up when the play starts.