Manages authenticated WebSocket user sessions in MeshCentral, handling real-time communication between browser clients and the server including device management, remote control, file operations, and event dispatching.
CreateMeshUser(parent, db, ws, req, args, domain, user)— Factory function that constructs a user session object bound to an active WebSocket connectionobj.send(object)— Serializes and sends JSON messages to the connected browser clientobj.close(arg)— Tears down the session (soft or hard disconnect), cleaning up timers, event dispatchers, and session registriesmeshPathToRealPath(meshpath, user)— Translates logical mesh path arrays (user or mesh-scoped) into validated server filesystem pathssendPing()/sendPong()— Keepalive heartbeat helpers for browser WebSocket connections- Rights constants — Bitmask enumerations for mesh rights (
MESHRIGHT_*), site rights (SITERIGHT_*), and user consent flags (USERCONSENT_*) - Protocol constants — Numeric identifiers for supported protocols (Terminal, Desktop, Files, AMT, WebRDP, WebSSH, WebSFTP, WebVNC)
const meshUser = require('./meshuser');
// Called internally by MeshCentral when a browser WebSocket connects
const userSession = meshUser.CreateMeshUser(
parent, // MeshServer parent object
db, // Database reference
ws, // Active WebSocket connection
req, // HTTP request (carries session data)
args, // Server arguments (e.g., browserping interval)
domain, // Domain configuration object
user // Authenticated user record
);
// Send a message to the browser
userSession.send({ action: 'info', message: 'Session ready' });
// Gracefully close the session
userSession.close(1); // 1 = soft close, 2 = hard TCP close- Session expiration is enforced via
req.session.expireusing asetTimeout - Cross-domain administration is gated by
managecrossdomainconfig; only a specific allowlist of message types are permitted cross-domain - Session counts are tracked in
parent.wssessionsand broadcast to peers in multi-server deployments viaparent.parent.multiServer
Source: meshuser.js