API Referencecommonutils
wsUtils Reference
Module defined in `lua/common/utils/wsUtils.lua`. WebSocket server creation and management utilities using BeamNG's `BNGWebWSServer` API.
Module defined in lua/common/utils/wsUtils.lua. WebSocket server creation and management utilities using BeamNG's BNGWebWSServer API.
Exports
Functions
M.createOrGetWS(listenAddr, port, path, protocolName, redirPage, enableDataStreams)
Create or retrieve an existing WebSocket server, auto-detecting the best network adapter.
- Parameters:
listenAddr- string - Listen addressport- number - Listen portpath- string - WebSocket path (e.g., "/")protocolName- string - WebSocket protocol nameredirPage- string|nil - HTTP redirect page for non-WS requestsenableDataStreams- boolean|nil - Enable data streaming (default: true)
- Returns: BNGWebWSServer, string - Server object and chosen IP address
Internal Notes
- Auto-tests each network adapter by creating a test client connection
- Skips VirtualBox and VMware virtual adapters
generateRandomDatacreates random strings for connection testingtestWSConnectionvalidates bidirectional data transfer before selecting adapter- Data streams enabled by default unless explicitly disabled
torqueScriptParser Reference
Module defined in `lua/common/utils/torqueScriptParser.lua`. Parses TorqueScript source code into an AST using PEG (Parsing Expression Grammar).
simpleProfiler/report Reference
Module defined in `lua/common/utils/simpleProfiler/report.lua`. Generates flame chart HTML reports from profiling data using Mustache templates.