Expand description
The newline-delimited JSON wire protocol. This module is its definition.
One JSON value per line in both directions. A client writes Request lines and reads
Frame lines, each either a Response echoing a request’s id or an unsolicited
EventFrame carrying a full StateSnapshot.
Field names and value spellings are the contract: new fields may be added and readers must ignore ones they do not recognise, but nothing already named may be renamed or respelled.
Structs§
- Download
Progress - One entry in a snapshot’s
downloadsarray. - Episode
Ref - The loaded episode, as much of it as a snapshot needs to name.
- Error
Object - A structured failure. Clients branch on
codeand never parsemessage. - Event
Frame - One event line:
{"event":{"type":"state","state":{...}}}. Events carry noid. - Preferences
- The interface’s own display preferences.
- Request
- One request line:
{"id":1,"cmd":{"type":"pause"}}. - Request
Error - A request line that could not be turned into a
Request, together with the response the daemon owes for it. - Response
- One response line. Carries exactly one of
resultorerror, and echoes the request’sid, ornullwhen the id could not be recovered from the line. - Spectrum
- A frequency spectrum of the audio currently being played.
- State
Snapshot - The complete player state.
Enums§
- Command
- The command surface the daemon accepts.
- Download
State - What a download is doing.
- Event
- The size difference between the two variants buys nothing to box away: an event is built, serialised, and dropped, and never held in bulk.
- Frame
- One line read from the daemon, which is either a response or a pushed event.
- Playback
State - What playback is doing right now.
- Result
Body - Source
- Where the audio for the loaded episode is coming from.
Constants§
- COMMAND_
TYPES - Every
cmd.typespelling the daemon recognises. - SPECTRUM_
BINS - How many frequency bins a
Spectrumcarries. - SPECTRUM_
MAX_ DB - The upper bound of the decibel range a
Spectrummaps onto0..=255. - SPECTRUM_
MIN_ DB - The lower bound of the decibel range a
Spectrummaps onto0..=255. - SPECTRUM_
SMOOTHING - The exponential smoothing applied against the previous frame.
Functions§
- parse_
request - Parses one request line, telling a malformed line from an unrecognised command from bad arguments, each of which the spec answers with a different code.