Add MrGameEng.Net: WebSocket transport + delta component replication
CI / build-test (push) Successful in 1m16s
CI / build-test (push) Successful in 1m16s
Browsers can't speak UDP, so WebSocket is the engine's one transport. The server side is a dependency-free RFC 6455 implementation over TcpListener (handshake, frame codec with masking and fragmentation, ping/pong — unit-tested against the RFC example vectors); the client wraps ClientWebSocket, which works on desktop and maps to the browser WebSocket in Blazor WASM. Both sit behind the poll-based INetConnection so simulation systems drain messages from their own thread; client sends are chained fire-and-forget (no blocking — wasm-safe). Replication is server-authoritative: games register unmanaged component types in a ReplicationSchema (same order both sides, up to 32 types), ReplicationServer snapshots entities carrying NetId once per send and ships each connection only the components that changed since its last snapshot — a reliable ordered transport needs no acks for deltas. New connections receive the full state through the same path; despawns are tracked by set difference. ReplicationClient applies snapshots to a local EntityStore and raises EntitySpawned so the game can decorate replicated entities with presentation components. Covered by 16 tests including a real loopback exchange between WebSocketClient and WebSocketServer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
10898b08a0
commit
3438ed77f6
@@ -64,6 +64,13 @@ Engine libraries (each feature is a namespaced subfolder of its host):
|
||||
**Collisions** (`MrGameEng.Collisions`: `Collider` component, spatial hash rebuilt per
|
||||
tick, pairs/queries/raycast, `scene.UseCollisions()` after movement systems).
|
||||
→ `Core`, `Graphics` (Collisions needs `Transform2D`, `RectF`).
|
||||
- **`Net`** — multiplayer building blocks, browser-compatible by design: a dependency-free
|
||||
RFC 6455 WebSocket server over `TcpListener` (browsers can't speak UDP, so WebSocket is
|
||||
the engine's one transport), a `ClientWebSocket`-based client (works in Blazor WASM),
|
||||
both behind the poll-based `INetConnection`; server-authoritative component replication
|
||||
(`ReplicationSchema` of unmanaged components, `ReplicationServer` sending per-connection
|
||||
deltas — no acks needed over a reliable ordered transport, `ReplicationClient` applying
|
||||
snapshots to a local store, `NetId`). → `Core`.
|
||||
- **`UI`** — Myra integration (`scene.UseUI()` after `UseRenderer2D()`),
|
||||
**DevConsole** (`MrGameEng.DevConsole`: in-game console capturing `Core.Log`,
|
||||
`scene.UseDevConsole()` last in OnLoad) and **Inspector** (`MrGameEng.Inspector`: a
|
||||
|
||||
Reference in New Issue
Block a user