Display rules
Choose the colour
Section titled “Choose the colour”Find your camera in the snapshot’s devices by ID, then check in this order:
- Your ID is not there → “Camera deleted”.
programorpreviewisnull→ Unknown. Unknown is not Off; never show it as Off.programistrue→ Program (red; if both aretrue, show Program).previewistrue→ Preview (green).- Both
false→ Off.
function tallyOf(snapshot, deviceId) { const device = snapshot.devices.find((d) => d.id === deviceId) if (!device) return 'deleted' if (device.program === null || device.preview === null) return 'unknown' if (device.program) return 'program' if (device.preview) return 'preview' return 'off'}While the switcher is not ready, the server sends null for every camera, so the client needs no extra check. To show the reason, read source.state (connecting, ready, disconnected) and source.error.
Disconnects and reconnects
Section titled “Disconnects and reconnects”- On a disconnect, timeout or error, show Unknown at once; never keep the last colour.
- Each reconnect brings a full snapshot; replace the old state with it.
- After a server restart the old
revno longer matches, so/poll/v1returns a new snapshot at once.
Compatibility
Section titled “Compatibility”- Ignore unknown fields and unknown message
types. - Within v1, fields are only added, never removed or changed in meaning. Removals or changes will come as a new version (
/ws/v2,/poll/v2), and the old version stays until all clients have upgraded.