Add a mesh scope to the Streams card

Local stays the default and the cheap path; mesh asks each partner for its own
sessions over SSH, live rather than cached, because a stream is true for
minutes and a cached one would be confidently wrong about the only thing the
card exists to say.
This commit is contained in:
Gmer4Lfe
2026-08-21 08:38:37 -04:00
parent 331b7b6b13
commit 81abc5adee
4 changed files with 202 additions and 8 deletions
+14 -2
View File
@@ -30,10 +30,22 @@
// RESPONSE
// vv_media_sessions() verbatim — a flat list of normalised sessions across all servers
//
// REQUEST
// GET this host's sessions
// GET ?scope=mesh every node's sessions, each row tagged with the host it is playing on
//
// Local is the default and stays the cheap path: one call per configured media server here.
// Mesh adds one bounded SSH hop per partner and is only requested while the operator is looking
// at the mesh view, so a dashboard left open on the default costs exactly what it did before.
//
// DEPENDS ON
// include/media.php vv_media_sessions()
// include/media.php vv_media_sessions(), vv_media_sessions_mesh()
// ═══════════════════════════════════════════════════════════════════════════════════════════════
header('Content-Type: application/json');
require_once dirname(__DIR__) . '/include/media.php';
echo json_encode(vv_media_sessions());
// Anything that is not the literal "mesh" is local. Fail-closed on the expensive path, matching
// how every other toggle in this plugin reads its value.
echo json_encode(($_GET['scope'] ?? '') === 'mesh'
? vv_media_sessions_mesh()
: vv_media_sessions() + ['scope' => 'local']);