aboutsummaryrefslogtreecommitdiffstats
path: root/live/server.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-18 08:15:50 -0700
committerAdam Soltys <[email protected]>2026-10-18 08:15:50 -0700
commit64826cb02e77dace0c4121d7c2a9d2d1c5163092 (patch)
tree37270288794fa5ab4f49f7ba581aaad0a2534825 /live/server.js
parent29688869753d7bc9f1d25db27b9fccc8f11266e1 (diff)
downloadcoinosv3-server-64826cb02e77dace0c4121d7c2a9d2d1c5163092.tar.gz
coinosv3-server-64826cb02e77dace0c4121d7c2a9d2d1c5163092.zip
live: /live/ping, a WebSocket that says pong — whether sockets get through to the service.
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013ZDf1cyCQLkfjftYhymZAg
Diffstat (limited to 'live/server.js')
-rw-r--r--live/server.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/live/server.js b/live/server.js
index 0e04aca..2aaa355 100644
--- a/live/server.js
+++ b/live/server.js
@@ -19,6 +19,7 @@
// GET /live/<id>/index.m3u8 everything so far; the recording once ended
// GET /live/<id>/<run>-<n>.ts a segment
// GET /live/<id>/stats {state, viewers, started, seconds}
+// GET /live/ping (WebSocket) says pong: sockets get through
//
// Who may send: a coinos name's owner (its nostr key or the wallet key that
// manages it), checked with the names registrar. One stream per person,
@@ -221,6 +222,8 @@ export async function handle(req, server) {
const url = new URL(req.url);
const path = url.pathname.replace(/^\/live/, '');
if (path === '/health') return json({ ok: true, live: live().length });
+ // a WebSocket that says pong: is the way in (Cloudflare, the proxies) open to sockets?
+ if (path === '/ping') return server.upgrade(req, { data: { ping: true } }) ? undefined : json({ error: 'websocket expected' }, 426);
if (path === '/ingest') {
const a = checkAuth(url);
if (a.error) return json({ error: a.error }, 401);
@@ -255,6 +258,7 @@ export const websocket = {
idleTimeout: 60,
open(ws) {
const d = ws.data;
+ if (d.ping) { ws.send('pong'); ws.close(1000, 'pong'); return; }
let s = d.resume ? streams.get(d.resume) : null;
if (!s) {
const id = randomBytes(8).toString('hex');