|
VR-Engage
2.3
|
The frontend handles visualization, input, and player interaction. The backend owns entity simulation and authoritative entity-state publication. Frontend components request backend changes through explicit connectors and transports. Ordinary application and Player Station attributes are process-local.
| Mechanism | Direction | Purpose |
|---|---|---|
| Joystick command | Frontend to backend | Request a configured group/function control input |
| State-property set request | Frontend to backend | Request a supported entity State Property change |
| Scripted extended-data set request | Frontend to backend | Request an entity extended-data key/value change |
| Reflected entity state | Backend/network to frontend | Consume published entity fields and properties |
| Explicit network-forwarded messages | Either direction when configured | Carry serialized messages selected by a bridge |
| Application/player attributes | Within one process | Share current frontend values |
Creating a serializable message does not automatically transmit it. The process-local message manager delivers it to registered handlers; a connector or forwarder must handle the transport boundary. See Frontend Attributes for local scopes and Reflected Entity Attributes for the entity-data bridge.
DtVreMessageManager::queueMessage(DtVreMessage*, double delay) takes ownership of the message. Do not delete it, retain it for later mutation, or reuse it after queuing. sendMessageAsap() can deliver immediately to handlers on the current registered dispatch thread; other deliveries remain queued.
Prefer the inherited myMessageHandlers group in a Player Station component. The saved-view updater registers related handlers this way:
The source includes the two message headers and inherits the group from DtPlayerComponent. Call base shutdown() to disconnect component-owned groups/callbacks before destroying their targets. Groups own handler objects, not callback targets. Connecting the same message-type string replaces that group's previous connection for the string. Use DtVreMessageHandler for a single retained callback or one callback connected to several types. See Toolkit Fundamentals for lifetime and cleanup distinctions.
Direct addHandler(type, delegate) remains supported, but it needs matching removeHandler() with the same type/delegate. The QML HUD and Custom PDU examples contain this explicit pairing. Do not copy only their registration line and omit cleanup.
| Result | Meaning |
|---|---|
IGNORED | This handler does not handle the message |
HANDLED | This handler handles the message; dispatch continues |
EATEN | Stop the current dispatch chain |
Handlers are assigned to their registration thread when that thread is a registered dispatch thread. Registration from an unregistered thread falls back to the main dispatch thread. Each dispatch thread processes its queue through dispatchTick(). Do not assume all callbacks execute synchronously on the sender or always execute on the frontend main thread.
Sources: include/utilities/vreMessageManager/vreMessageManager.h, vreMessage.h, and libsrc/utilities/vreMessageManager/vreMessageManager.cxx.
The maintained Custom PDU example defines this message schema:
The library's CMakeLists.txt calls the existing generateMessages() helper with its namespace, export macro, export header, and schema directory. The generated class is makVre::CommentMessage. Edit the Lua definition, not generated message headers. See Custom PDU for the complete generation and registration project.
The example's network connector explicitly translates internal messages to VR-Link Comment interactions. Its install/shutdown methods add/remove both the internal handler and VR-Link callback. The excerpt below retains its message/type and sender filtering:
The source includes commentConnector.h, commentMessage/commentMessage.h, vreMessageManager/vreMessageManager.h, and vl/exerciseConn.h. The installed connector supplies myConnection and the ownship sender ID. This sends an interaction, not authoritative entity state from the frontend.
The message manager accepts hierarchical type strings and wildcard subscriptions. Use actual schema type strings rather than assuming a prefix from a class name. The simulation plugin's configureNetworkForwarder() explicitly selects patterns such as net.*, entity.query.*, and entityState.*. A new arbitrary message type is not automatically covered by those selections.
Frontend input logic loads mappings and invokes control-logic action callbacks. The vehicle blinker control logic initializes its base, validates joystickFunctionGroups, loads the "lights" mapping group, and registers left/right blinker actions. Its sender is:
The source includes vreMessages/joystick.h, vrePlayerStation/playerStation.h, and vreMessageManager/vreMessageManager.h. The header supplies the default delay. The group is cached from the role configuration during initialization; it is not an invented group label. The message schema also contains a repeat flag; this sender leaves its generated default unchanged.
DtOwnshipControlConnector::handleJoystick() runs in the frontend connector layer:
The remote-controller request reaches the backend's VR-Forces joystick system. The handler above forwards entity/group/function/value; it does not forward the repeat flag. See VR-Forces Integration for controller interfaces, port wiring, and authority.
VrfSetStatePropertyMessage is a frontend-to-backend command, not a backend state-update notification. Supply an entity ID, property name, property type, and string value. DtOwnshipControlConnector::handleSetStateProperties() creates the corresponding Reader/Writer property, puts it in DtSetStateProperties, and sends a VR-Forces set-data request through the remote controller. Supported message types are String, Bool, Int, Real, and Vector3d.
See Request a backend state-property change for the real drone helper and libsrc/framework/vreMessages/vrfEntitySetDataRequests.lua for the schema. Validate values against the connector's parser and the target entity's declared property. Queuing a request neither changes a local reflected value immediately nor acknowledges backend success.
Backend components update the entity's next-frame State Properties. The entity-state publication path carries the authoritative result; the reflected-entity connector populates requested fields under Root.Entities.<id>.stateProperties. A QML overlay reads that reflected path or a player attribute published by a frontend adapter. It does not receive VrfSetStatePropertyMessage as a state update.
The vehicle blinker actuator locates declared boolean properties in init() and toggles them in tick(). Its newData() checks are followed by dataReceived() acknowledgements. See Actuator input port consumption and State Properties for the actual producer/consumer contracts.
DtPlayerComponent::setExtendedData(key, value, entity) creates VrfScriptedEntitySetMessage with script name set_extended_data and string variables key/value. The optional target entity defaults to ownship. DtOwnshipControlConnector::handleScriptedSet() converts the variables to a VR-Forces scripted set-data request and sends it to the target's simulation owner. Use this command path for supported backend keys, not a write to an arbitrary local attribute.
The maintained consumer is data/simulationModelSets/VR-Engage/scripts/set_extended_data.lua. Its adjacent XML metadata declares the script ID and string inputs. init() enables ticking while paused; its tick contains:
The compatible VR-Forces vrfobjcore/scriptVrfObject.h implements that Lua binding through setNextFrameExtendedData(). The entity owner then publishes the updated state. Keep the script and metadata available in the receiving model set.
Published extended-data values are strings. The reflected connector exposes requested keys under extendedData, with typed child conversions when configured/requested. DtExtendedStateLogic is a frontend adapter that aliases requested reflected extended-data and State Property nodes into the Player Station branch. Those aliases remain connector-owned; they are not independent writable player values or backend commands. See Extended Data for types, interest lifetime, and missing-value behavior.
Use messages for commands/events and attributes for current local state. For IPC, identify the actual handler/transport and verify both producer and consumer. Keep one owner per attribute, retain interest handles, and disconnect callbacks before releasing resources. Do not pool or reuse message objects after passing ownership to the message manager.
Network delay and missing responses need explicit handling. Do not treat an unset attribute's default value as evidence that a backend producer has run. Message callbacks follow dispatch-thread registration; attribute callbacks follow their own registration and dispatch rules. Neither mechanism makes unrelated shared data or object lifetimes thread-safe.
Check the schema type, registration lifetime, dispatch thread, connector installation, and transport selection. For reflected data, check the exact case-sensitive scope, entity presence, requested child, and isSet(). Use current logging APIs from vreUtil/logger.h: printf-style LOG_*(channel, format, ...) or LOG_*_STREAM(channel) for streams. There is no verified debugSettings.lua/traceMessages configuration or fixed sample log transcript supplied by this guide.
VR-Link supplies DIS/HLA interoperability. The backend publishes authoritative entity state through VR-Forces and VR-Link; frontend connectors consume reflected state and send supported remote-control requests. Use maintained connection settings/startup scripts and the product's protocol-specific configuration. An invented Lua network = {...} table is not a verified VR-Engage exercise configuration.
See also