Skip to content

examples: templated WebSocket echo server and browser client#156

Draft
timfox wants to merge 6 commits intomainfrom
cursor/websocket-templated-examples-f2d7
Draft

examples: templated WebSocket echo server and browser client#156
timfox wants to merge 6 commits intomainfrom
cursor/websocket-templated-examples-f2d7

Conversation

@timfox
Copy link
Copy Markdown
Owner

@timfox timfox commented Apr 27, 2026

This change adds examples/websocket/ with self-contained templates for demonstrating WebSockets alongside the engine client:

  • Node ws server (server/node/echo_server.mjs): echo text; responds to JSON {"type":"ping"} with a pong and timestamp. npm install and node echo_server.mjs (default port 8765).
  • Browser one-page client (client/browser/echo_client.html) with connect, send, JSON ping, and a log.
  • Engine copy-paste sketch (engine_snippet.c) showing WS_Connect / WS_SendText / callbacks; documents that WS_Frame is already driven from cl_main.c and that the built-in client is ws:// (TLS at reverse proxy for wss://).

package-lock.json is included so the Node example is reproducible without re-running npm install in CI context.

Open in Web Open in Cursor 

cursoragent and others added 6 commits April 27, 2026 19:39
r_forwardPlusShade changes PBR fragment specialization on world draw pipelines
only. vk_destroy_pipelines() also destroyed gamma, overlay compose, bloom,
SMAA, and other post paths unrelated to Forward+, which could leave the
swapchain with no valid gamma blit (black screen with audio).

Add vk_destroy_world_graphics_pipelines() (same slice as vk_release_resources:
indices >= vk.pipelines_world_base) and use it for r_forwardPlusShade
invalidation. Persistent pipelines (skybox, fog, etc.) stay valid; PBR world
pipelines are recreated lazily via vk_gen_pipeline as before.

Co-authored-by: Tim Fox <timfox@outlook.com>
vk_destroy_world_graphics_pipelines() must not shrink vk.pipelines_count or
zero Vk_Pipeline_Def rows: shader_t stores uint32_t indices into the table;
dropping the tail reuses slots and breaks cached indices (wrong draws or
vk_gen_pipeline ERR_FATAL). Destroy only VkPipeline handles; lazy recreation
picks up the new r_forwardPlusShade specialization.

Co-authored-by: Tim Fox <timfox@outlook.com>
- r_forwardPlus default 1 (latched): prioritize clustered tile cull + PBR path
- Light records: pack to host staging, vkCmdCopyBuffer to DEVICE_LOCAL SSBO each
  frame so compute cull and fragment shaders read VRAM (not host-mapped SSBO)
- vk_forward_plus_upload_refdef after RB_BeginDrawingView: transfer barriers
- Tile cull light buffer barrier updated for device-local read path
- docs/FORWARD_PLUS_PIPELINE_AUDIT.md: ordering and sync notes

Startup log: [VK][Forward+] r_forwardPlus=1 device-local light SSBO + staging...

Co-authored-by: Tim Fox <timfox@outlook.com>
Move record/demo/stoprecord commands, demo file I/O, and net-packet
demowriting from cl_main.c into cl_demo.c. cl_main calls
CL_Demo_InitCommands/Shutdown and CL_Demo_WriteServerPacket for live
recording. Public entry points (CL_ReadDemoMessage, CL_StopRecord_f)
remain in cl_demo.c for cl_parse and cgame.

Co-authored-by: Tim Fox <timfox@outlook.com>
Co-authored-by: Tim Fox <timfox@outlook.com>
Add examples/websocket with a Node ws echo server (JSON ping/pong),
a single-file HTML client, an engine WS_* API snippet, and README notes
on ws:// vs TLS and how the client integrates with WS_Frame().

Co-authored-by: Tim Fox <timfox@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants