code wiki / _hdl_build / nx_mp_daemon.nx

nx_mp_daemon.nx

buildroot/runtime/_hdl_build/nx_mp_daemon.nx

5422 B119 linesdepth 2pulls 4 transitivereach 2 importersview sourcekind librarytopic mp
docsdependenciesstructsconstsfunctions

about

nx_mp_daemon.nx -- sovereign request-handler for the multiplayer player-state relay (the /pstate POST + /roster GET routes). A LIBRARY (no main) so it is gate-testable without sockets and then dropped into the socket accept/fork loop (mirrors nx_arcade_serve). The relay lives in SHARED mmap so every forked handler sees it. Composes nx_room_relay (rr_post) + nx_mp_relay (mp_roster_body). Pure parsing + buffer ops. /pstate?r=<room>&p=<peer> (POST, body = the wasm's packed snapshot bytes) -> rr_post into the room /roster?r=<room>&p=<self> (GET) -> mp_roster_body of the OTHER live peers, as an octet-stream body The browser host does ONLY: snapshot->POST, GET->memcpy->gi_net_ingest_roster. Zero net logic in JS. license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_mp_relay.nx nx_mp_daemon.nx nx_mp_daemon_gate.nx nx_mp_serve.nx

imports: nx_syscalls.nxnx_mp_relay.nx

imported by: nx_mp_daemon_gate.nxnx_mp_serve.nx

structs

none

consts

11const K_MAGIC_4096: i64 = 4096

functions

14func mpd_path(req: *u8, n: i64, out: *u8) -> i64
called by 2: mainmain
30func mpd_starts(s: *u8, pre: *u8) -> i64
called by 1: mpd_route
36func mpd_route(path: *u8) -> i64
called by 2: mainmain calls 1: mpd_starts
41func mpd_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: mpd_qint
43func mpd_qint(path: *u8, key: *u8) -> i64
called by 3: mpd_pstatempd_rostermain calls 1: mpd_slen
69func mpd_body_off(req: *u8, n: i64) -> i64
called by 2: mpd_pstatemain
77func mpd_wstr(buf: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { buf[off + i] = s[i]; i = i + 1 } return off + i }
78func mpd_wn(buf: *u8, off: i64, v: i64) -> i64
called by 3: mpd_rostermk_postmain calls 1: sys_mmap
91func mpd_pstate(req: *u8, n: i64, path: *u8, st: *i64, arena: *u8, slotb: i64, now: i64, out: *u8) -> i64
106func mpd_roster(path: *u8, st: *i64, arena: *u8, slotb: i64, now: i64, ttl: i64, out: *u8) -> i64