Connection

STD Plus uses Socket.IO for real-time WebSocket communication.
SettingValue
Path/api/socket-entry
Namespace/ (default)
AuthJWT token via handshake

Connecting

import { io } from 'socket.io-client';

const socket = io('http://localhost:3000', {
  path: '/api/socket-entry',
  auth: { token: 'your-jwt-token' },
});

socket.on('connect', () => {
  console.log('Connected:', socket.id);
});

socket.on('connect_error', (err) => {
  console.error('Connection failed:', err.message);
});

How Rooms Work

The WebSocket uses a room-based architecture. Clients join rooms to subscribe to specific data events:
Client connects
  └─ auto-joins: user:<userId>
  └─ manually joins: dashboard, inventory, order, etc.
  └─ dynamic rooms: station:<stationId> (per-station)
When data changes via the REST API, the server emits events to the relevant rooms. Only clients in that room receive the event.
You must join a room before you can receive its data events. Use join_* events when navigating to a page, and leave_* events when navigating away.

Event Directions

DirectionMeaningExample
OUTBOUNDClient sends to serverjoin_dashboard, leave_order
INBOUNDServer sends to clientorder:updated, notification

Room-to-Event Mapping

RoomEvents received
user:<id>notification
dashboardAll :updated events
inventorymaterial:updated, inventory:updated
loglog:updated
requestrequest:updated
withdrawalwithdrawal:updated
orderorder:updated
claimclaim:updated
panepane:updated, laminate:ready, pane:laminated
productionpane:updated, production-log:updated, laminate:ready, pane:laminated
pricingpricing:updated
stationstation:updated, station-template:updated, station:pane_arrived
station:<stationId>station:check_in, scan-confirmed, station:pane_arrived, notification (order arrived), laminate:ready, laminate:waiting, pane:laminated
(broadcast)system_alert