tracker
All repositories: gitoria
4.0 KB
\* hl:http1 — the native WebSocket server. Subclass it (`inheritNativeWebSocketServer`) and answer the declared events below; eachconnected peer arrives as a WsClient (send/ping/close). AUTO-LISTEN: thefile root IS the constructor and ends with listen(), so`new NativeWebSocketServer(port = 8888)` serves immediately. *\/* Mission 064 (decision D9): the h1 plugin performs the RFC 6455 Upgrade/101handshake and framing (shared core plugins/http/ws_common.zig); thiswrapper maps the native event stream onto on/emit, mirroringNativeHttpServer. A SUBCLASS does not inherit this run body and callslisten() from its own root. */\* A peer completed the upgrade and is connected. *\emit connect(WsClient client \\ the new peer — send/ping/close)\* A complete text (or binary) message arrived from a peer. *\emit message(WsClient client \\ who sent itString data \\ the message payload)\* The peer answered a client.ping(). *\emit pong(WsClient client \\ who answered)\* A connection ended — the peer is already unregistered. *\emit close(WsClient client \\ who left)\* OPTIONAL: plain HTTP answered on the same port, exactly asNativeHttpServer's request. *\emit request(Hybrid req \\ method, path, headers, body, bytes, params, respond)Number port = 8080 \\ the port listen() bindsString host = "0.0.0.0" \\ the interface to bindNumber threads = 4 \\ I/O worker threadsBoolean listening = false \\ true after a successful bindHybrid clients = {} \\ live WsClients by connection idNumber #srcId = 0Number #wsSrcId = 0\* Bind the configured port and start the WebSocket engine (idempotent). *\listen() {if (listening == true) {return null}srv = __native("http1.create_server", port, host, "", "", threads)if (srv == null) {// A REFUSAL, NOT PROSE (mission 286) — same reason as NativeHttpServer's.hlError("hl:http1: listen() failed: could not bind port " + port + " on " + host + " — the port is already taken. The line just above, 'bind() failed on port " + port + "', names the process holding it: stop that process, or start this app on another port (--port N, or HL_PORT=N)")}wsev = __native("http1.ws_events")listening = true#srcId = __native("eventloop.register", srv, "request")#wsSrcId = __native("eventloop.register", wsev, "wsEvent")}\* One text frame to EVERY connected peer; answers how many received it. *\broadcast(String text \\ the frame to send) {return __native("http1.ws_broadcast", text)}\* Stop this server: both event sources retired, workers joined, listenerclosed — the port is free again. Answers false when not listening. *\close() {if (listening == false) {return false}listening = false__native("eventloop.unregister", #srcId)__native("eventloop.unregister", #wsSrcId)return __native("http1.close", port)}// Raw native events ({ kind, id, data, binary, code }) re-emitted as the// documented surface — emit is the universal primitive.on wsEvent(ev) {key = "c" + ev.idif (ev.kind == "connect") {client = new WsClient(ev.id, ev.cookie, ev.host != '' ? ev.host : null, headerHash(ev.headers)) // the upgrade's cookie, host and headers ride with the connection (creator, 2026-09-12; tickets #74, #105)clients[key] = clientemit connect(client)}if (ev.kind == "message") {client = clients[key]if (client != null) {emit message(client, ev.data)}}if (ev.kind == "pong") {client = clients[key]if (client != null) {emit pong(client)}}if (ev.kind == "close") {client = clients[key]clients[key] = nullif (client != null) {emit close(client)}}}// The upgrade's headers arrive as `name: value` lines (names already lowercase);// a connection is handed them as a hash (ticket #105).headerHash(lines) {let nl = ""let out = {}if (lines == null || lines == '') { return out }for (line of lines.split(nl)) {let colon = line.indexOf(': ')if (colon > 0) { out[line.slice(0, colon)] = line.slice(colon + 2) }}return out}// Run body: bind the configured port (idempotent, like NativeHttpServer).listen()
Branches
- mainmain branch
Latest commits
- 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
- 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
- 47a3cae6STATUS: mission 053 merge commit idsmre
- dcc5eecaMerge branch 't14-search'mre
- 03edc783Merge branch 't15-tvmaze'mre
- 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
- 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
- b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
- 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
- 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
- cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre
- b105bcd8tracker#11: Hybriel master ff51cf46 (checks no longer vanish), mobile-first styles, carets, follow button, sign-in modal, inverted check, orange castmre
- 31b758aatracker#10: installable app (manifest, service worker, offline shell), own icon + faviconmre
- 2fa9d997tracker#9: TMDB sync (followed shows: seasons, episodes, posters), tools/sync-tmdb.hl + daily run 04:00 UTC, fake TMDB in gatemre
- 49e1f61edeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- 54070a4etracker#8: /my/unwatched + /my/schedule (301 from old), S01E01, title (year), 1 episode, watched-set lookup (unwatched 15s -> 1s)mre
- 3251488atracker#7: /my/shows (followed shows, newest follow first, poster, title, last watched SxxEyy); gate can take screenshots (TRACKER_GATE_SHOTS)mre
- 44b7d9f9tracker#6: /schedule — upcoming episodes of followed shows, soonest firstmre
- 91c9fc8ctracker#5: /unwatched — unwatched released episodes of followed shows, newest firstmre
- a97c0295tracker#4: show page /shows/:slug (header, seasons, episodes, watch checks) + tools/relink-episode-seasons.hlmre