jukebox
All repositories: gitoria
3.4 KB
\* hl:http1 — module exports beside the class surface (NativeHttpServer,NativeWebSocketServer, Response, WsClient in their own files). *\\* Bind a plain HTTP/1.1 listener; answers the request event source. *\listen(Number port \\ the port to bind) {return __native("http1.listen", port)}\* The full-featured constructor: interface, TLS pair, worker count. *\create_server(Number port \\ the port to bindString host = '0.0.0.0' \\ the interfaceString cert = null \\ PEM certificate path — with key, serve httpsString key = null \\ PEM key pathNumber threads = 4 \\ I/O worker threadsNumber maxBody = 20971520 \\ largest request body read, bytes; over it: 413Boolean wsCheckOrigin = false \\ 403 a WebSocket upgrade with a foreign OriginString wsOrigins = "" \\ extra allowed origins, comma-separated) {return __native("http1.create_server", port, host, cert, key, threads, maxBody, wsCheckOrigin, wsOrigins)}\* A cookie-grade random token: n lowercase hex characters read from theKERNEL's CSPRNG, never a seeded PRNG — a session id is the only thingbetween a stranger and someone else's session (hl:math's random() is aclock-seeded xoshiro whose state a handful of outputs reveal). Lives herebecause the session cookie is an HTTP artifact. *\randomToken(Number n \\ how many hex characters) {return __native("http1.random_token", n)}\* SERVER-SENT EVENTS (ticket #144) — the push channel, imported by name like anyother export: import { sseStart, sseSend } from 'hl:http1'. A static or a methodcalls them; the browser build of a file that imports them binds each to a refusalthat throws only if the browser CALLS it (hl:http1 ships no browser half).let conn = sseStart(req.respond) \\ the GET is now a text/event-streamsseSend(conn, JSON.stringify(row)) \\ one `data:` frame to that clientA stream lives until its client goes: hl:http1 reaps a closed one at once (FIN) orat the next ":" heartbeat (every 5 s), and a push to it answers false. Plain HTTPonly — on hl:http1's own TLS, sseStart answers null (end TLS in a proxy). *\\* Turn this request into a Server-Sent Events stream: writes the 200text/event-stream head and keeps the socket open. Answers the CONNECTION ID theother sse calls address, or null when the request was already answered (or is TLS). *\sseStart(Hybrid respond \\ the request's respond handle: req.respond) {return respond.call("sse_start")}\* One frame to one stream: `data: <text>` and the blank line. A text withnewlines continues the frame (a line after the first is its own field, e.g.'id: 42'). Answers true when it was written, false when that stream is gone. *\sseSend(Number conn \\ the id sseStart answeredString text \\ the frame's data, usually JSON.stringify(...)) {return __native("http1.sse_send", conn, text) == 1}\* The same frame to every open stream; answers how many got it. *\sseBroadcast(String text \\ the frame's data) {return __native("http1.sse_broadcast", text)}\* Is the stream still open? Asks the registry, pushes nothing. *\sseAlive(Number conn \\ the id sseStart answered) {return __native("http1.sse_alive", conn) == 1}\* Close one stream; answers true if closed, false when already gone. *\sseClose(Number conn \\ the id sseStart answered) {return __native("http1.sse_close", conn) == 1}\* How many streams are open now. *\sseCount() {return __native("http1.sse_count")}
Branches
Latest commits
- 10f8a8c8Merge branch 'code-order' into mainJukebox
- 204fc828Merge branch 'day72' into mainJukebox
- 95f5faae|||PR jukebox#7 Drop needless let declarationsmre
- 33072bb5|||PR Record day72 gates and Chrome proofmre
- 95f2cd73|||PR Use typed parent methods for screen playback and local server facesmre
- 6422a020Sync media-player at 51c3818mre
- b582ba1cVendor complete Hybriel day72 plugin setmre
- 02dccbc9Merge branch 'records-1119' into mainJukebox
- a39e1c23|||PR Records: missions 013-015, reconnect fix livemre
- fc7db075Merge branch 'reconnect-retry' into mainJukebox
- ac6f4c6fL2: plain declaration for a in pickedNextmre
- 2f335086Review round 2: only an explicit queue pick drops pend (not the automatic advance); jb23 records every source changemre
- 3eb6695fReview fixes: action generation, queue pick clears pend, Previous/Next retry the decided request, typed handlersmre
- 7a53c0c2|||PR A tap lost to a dead socket plays after reconnect (mission 015)mre
- 1f0cd77bMerge branch 'records-day41' into mainJukebox
- 67be229f|||PR Records: day41 live (PR #4), mission 012, statusmre
- 0bb027daconductor: caramboleyo is the user, not owner/creatorApollo
- 04f5d9d5Merge branch 'day41' into mainJukebox
- 8ed6da45|||PR README: media-player pin df9e7dfmre
- d5d45fc3|||PR media-player df9e7df (repeat-one fix), sync pin and SOURCEmre