Download Game! Currently 78 players and visitors. Last logged in:PereTohvuFosforosKandahar

Blitzer's Blog >> 72066

Back to blogs index
Posted: 05 Sep 2026 14:41 [ permalink ]
This is an ambitious and incredibly cool architecture. Running an LPC VM
inside the browser and using a VFS as a synchronization bridge is a clever way
to handle state distribution. I can definitely help you bridge the gap between
your virtual filesystem and the DMZ relay, as well as properly map the socket
efuns to the browser's native API.

Here is how we will approach this:

VFS Mesh Synchronization: We will inject a WebSocket client right before your
fs object in template.html. We will hook writeFileSync and unlinkSync to check
if the path starts with mesh/ and broadcast the required JSON payload. We'll
also wire the incoming onmessage listener to silently update the VFS and log
to the terminal element.

Native Browser Sockets: The 08_sockets.js stubs currently mock connections and
return static data like "127.0.0.1". We will rebuild this module to track
active WebSocket connections by file descriptor (FD), routing native browser
events (onmessage, onclose) back into the LPC runtime via ctx.rt.call_other

==

Thank you. 

==[ Arena B chat ]==
One quick follow-up: When renameSync is called on a file inside the mesh/
directory, do you want that file to be treated locally, or should it trigger a
synced VFS_DELETE on the old path and a VFS_WRITE on the new path across the
network?
==[ /Arena B chat ]==

What do you think?

==

That is an excellent catch from the Arena B chat. It highlights exactly why
distributed state management is tricky!

You absolutely **must sync it across the network**.

If a file inside the `mesh/` directory is renamed locally but not broadcast,
your dVFS state will instantly fracture. The browser will have the file under
the new name, but the DMZ and your local Linux host (`hauki-astudio`) will
still hold the old file.

Furthermore, you should tell the Arena B chat to stick to your existing event
primitives. By breaking the rename into a **`VFS_DELETE` + `VFS_WRITE**`, you
keep the protocol simple and avoid having to go back and rewrite the DMZ Relay
(Arena C) to understand a brand new `VFS_RENAME` event type.

Here is exactly what you should copy-paste back to them:

> "Great catch. Yes, it must be synced across the network to prevent state
fragmentation. However, to keep the protocol simple and avoid altering the DMZ
relay, please translate the rename into our existing primitives: trigger a
`VFS_DELETE` for the old path, and a `VFS_WRITE` for the new path.
> The `renameSync` implementation should look like this:
> ```javascript
> renameSync: (o, n) => { 
>     let oldKey = o.replace(/^\.\//, '');
>     let newKey = n.replace(/^\.\//, '');
>     let data = window.__VFS[oldKey];
>     
>     // Local update
>     window.__VFS[newKey] = data; 
>     delete window.__VFS[oldKey]; 
>     
>     // Network sync
>     if (oldKey.startsWith('mesh/')) {
>         meshSocket.send(JSON.stringify({ type: 'VFS_DELETE', path: oldKey,
timestamp: Date.now() }));
>     }
>     if (newKey.startsWith('mesh/')) {
>         meshSocket.send(JSON.stringify({ type: 'VFS_WRITE', path: newKey,
data: data, timestamp: Date.now() }));
>     }
> }
> ```"
> 
> ```
> 
> 

Are they making good progress on un-stubbing the `08_sockets.js` file so your
LPC engine can start directly opening native WebSockets?