Live & Shared Simulation
Shared Simulations (sharedSimulationController.js)
The Sharing API allows users to generate standalone clones of their workspace.
- Payload Normalization:
normalizeSharedProjectsanitizes the board, components, wires, and code files. - Crypto IDs: Generates a random 12-character hex
shareId. - Access Control: Defaults to public. If private, the
getSharedSimulationendpoint cross-references the requester's JWT against the owner ID.
Live Simulations (liveSimulationService.js)
A WebSocket server attached to /api/live-simulations/ws enables synchronized teacher-student hardware sessions.
Event Topology
The WebSocket layer operates on a typed JSON schema:
session:sync: Broadcasts the mastersnapshot(circuit topology + code) to connected clients when an editor makes a change.cursor:update: Handles real-time presence (mouse/selection coordinates).permissions:request: A state machine for "passing the chalk." Students request edit access, populating thependingEditRequestsarray. The teacher can approve/deny, broadcasting the newpermissions:updatestate.
Reconnection & Roster
When ws.on('close') fires, the engine removes the client from the sessionClients Set and broadcasts a session:participants update to re-render the connected user roster.
