RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Debug DrawingGPU Mesh StructsImGui FFIMath Structs (FFI)FFI C DefinitionsPID ControllersCSV LibraryDelay LineDequeDevelopment UtilitiesEvent ReferenceExtension SystemSignal FiltersGraph PathfindingUI BridgeInput Filter Constants2D Bilinear InterpolationIntrospectionJBeam Pretty PrinterJSON AST ParserSJSON ParserJSON Debug ParserJSON Pretty PrinterK-D Tree (2D Boxes)K-D Tree (3D)K-D Tree (3D)Lua SerializerC++/Lua BindingLua CoreLua ProfilerMath LibraryParticlesQuadtreeSettingsTCP ServerTimer SchedulerUtility Library
Call TracerDate UtilsDebug DrawingFilter Chainutils/ - Utility ModulesHeatmap GeneratorHTTP JSON ServerInteractive ShellLanguage MapPerformance ProfilerPixel Drawing LibraryHTTP ServerTorqueScript ParserWebSocket Server

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API Referencecommonutils

WebSocket Server

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 address
    • port - number - Listen port
    • path - string - WebSocket path (e.g., "/")
    • protocolName - string - WebSocket protocol name
    • redirPage - string|nil - HTTP redirect page for non-WS requests
    • enableDataStreams - 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
  • generateRandomData creates random strings for connection testing
  • testWSConnection validates bidirectional data transfer before selecting adapter
  • Data streams enabled by default unless explicitly disabled

See Also

  • utils/ - Utility Modules - Directory overview
  • calltracer Reference - Related reference
  • dateUtils Reference - Related reference
  • debugDraw Reference - Related reference
  • Common Libraries Overview - Guide

TorqueScript Parser

Module defined in `lua/common/utils/torqueScriptParser.lua`. Parses TorqueScript source code into an AST using PEG (Parsing Expression Grammar).

Profiler Report

Module defined in `lua/common/utils/simpleProfiler/report.lua`. Generates flame chart HTML reports from profiling data using Mustache templates.

On this page

ExportsFunctionsM.createOrGetWS(listenAddr, port, path, protocolName, redirPage, enableDataStreams)Internal NotesSee Also