docs: add Networking section + process/OS builtins (net_send, owner, is_server, serialize/apply, arg, exit, run, getenv, read_char, file_*)
All checks were successful
docs / build-and-deploy (push) Successful in 1s

Sourced from the compiler's confirmed builtin set and NETWORKING-DESIGN.md, so
the reference reflects the current language surface. 93 -> 104 symbols.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-08-29 16:39:29 +03:00
parent ccef707e4c
commit 25f987e30d
17 changed files with 144 additions and 5 deletions

View file

@ -0,0 +1,7 @@
---
id: networking
title: Networking
order: 9
---
Multiplayer is a compile-time property of the ECS, not glue you thread by hand. Mark fields <code>@Sync</code> and models <code>@Owned</code>; the compiler generates the replication. These are the low-level primitives beneath that sugar, for when you drive the transport yourself.

View file

@ -0,0 +1,12 @@
---
id: fn-is_server
name: is_server / is_owner / local_id
category: networking
kind: builtin
tokens: is_server is_owner local_id
sig: is_server() -> bool is_owner(e) -> bool local_id() -> int
tip: Role and identity checks the runtime sets.
order: 3
---
The runtime sets the local role. <code>is_server()</code> is the authority check, <code>is_owner(e)</code> is true when this peer owns <code>e</code>, and <code>local_id()</code> is this peer's id. Prefer role annotations to sprinkling these through gameplay code.

View file

@ -0,0 +1,12 @@
---
id: fn-net_poll
name: net_poll
category: networking
kind: builtin
tokens: net_poll
sig: net_poll(buf, cap) -> int
tip: Receive queued bytes from the transport; returns the byte count.
order: 1
---
Copy up to <code>cap</code> waiting bytes into <code>buf</code> and return how many arrived (0 when nothing is queued). Pair it with the generated <code>apply</code> to fold an update back into the world.

View file

@ -0,0 +1,12 @@
---
id: fn-net_send
name: net_send
category: networking
kind: builtin
tokens: net_send
sig: net_send(peer, buf, len)
tip: Send bytes to a peer over the host's transport.
order: 0
---
Send <code>len</code> bytes from <code>buf</code> to <code>peer</code>. The transport itself is a host-provided seam — UDP natively, WebRTC/WebSocket on the web, or a loopback in tests — so the same game runs over any of them.

View file

@ -0,0 +1,12 @@
---
id: fn-owner
name: owner / set_owner
category: networking
kind: builtin
tokens: owner set_owner
sig: owner(e) -> int set_owner(e, id)
tip: Read or assign an entity's network owner.
order: 2
---
<code>@Owned</code> gives a model an owner slot; <code>owner(e)</code> reads the peer id that owns entity <code>e</code> and <code>set_owner(e, id)</code> assigns it (the authority decides). Ownership gates who may write <code>@Sync(to: owner)</code> fields.

View file

@ -0,0 +1,12 @@
---
id: fn-serialize
name: serialize / apply
category: networking
kind: builtin
tokens: serialize apply
sig: serialize(e, buf) -> int apply(e, buf, len)
tip: Compiler-generated per-model replication of @Sync fields.
order: 4
---
Generated from the ECS schema per model: <code>serialize</code> writes an entity's <code>@Sync</code> fields into <code>buf</code> and returns the length; <code>apply</code> folds received bytes back onto an entity. Together they are the replication substrate the sugar builds on.