VR-Engage  2.2
Loading...
Searching...
No Matches
exerciseConnNetForwarder.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file exerciseConnNetForwarder.h
7//! \brief Defines a network forwarder for VREngage messages using exercise connections
8//!
9//! This file contains the DtExerciseConnNetworkForwarder class which implements
10//! message forwarding through an exercise connection using the communication manager.
11//! It handles bundling of outgoing messages for efficiency and processes incoming
12//! data events from the network, enabling distributed communication between VREngage
13//! components across a network.
14
15#pragma once
16
20
21#include <boost/signals2.hpp>
22
23class DtCommunicationManager;
24
25namespace makVrfEvents
26{
27class DtEvent;
28}
29
30namespace makVre
31{
32//! \brief Parameter ID used to identify VREngage messages in data events
33//!
34//! This constant is used to filter data events that contain VREngage messages
35//! when receiving network traffic through the exercise connection.
36const int DtVrEngageDatumParamId = 2000000;
37
39
40//! \brief Network forwarder that uses an exercise connection to send and receive VREngage messages
41//!
42//! This class implements a network forwarder that uses the exercise connection
43//! (via a communication manager) to send and receive VREngage messages over the network.
44//! It bundles outgoing messages for efficient transmission and processes incoming
45//! data events from the network. The forwarder ensures messages are only processed once
46//! by tracking the originating application ID of each message.
48{
49public:
50 //! \brief Constructor
51 //! \param factory Pointer to the message factory for creating messages from raw data
52 //! \param exerciseConn Pointer to the communication manager for the exercise connection
53 //!
54 //! Initializes a new exercise connection network forwarder with the specified
55 //! message factory and communication manager. The message factory is used to
56 //! create messages from incoming raw data, and the communication manager is used
57 //! to send outgoing messages through the exercise connection.
58 DtExerciseConnNetworkForwarder(makVre::DtVreMessageFactory* factory, DtCommunicationManager* exerciseConn);
59
60 //! \brief Virtual destructor
61 //!
62 //! Cleans up resources, including any remaining message bundles.
64
65 //! \brief Flushes bundled messages to the network
66 //!
67 //! This method sends all accumulated message bundles to the network through
68 //! the exercise connection. Because messages are bundled for efficiency, this
69 //! method should be called once per frame to ensure timely delivery of messages.
70 //! After sending, each bundle is reset for reuse in the next frame.
71 //!
72 //! \note This must be called once per frame to ensure messages are transmitted
73 virtual void flush() override;
74
75 //! \brief Enables the network forwarder
76 //! \return True if the forwarder was successfully enabled
77 //!
78 //! This method enables the network forwarder by connecting to the data event
79 //! signal of the communication manager's event manager. When enabled, the
80 //! forwarder will process incoming data events and forward outgoing messages.
81 virtual bool enable() override;
82
83 //! \brief Disables the network forwarder
84 //!
85 //! This method disables the network forwarder by disconnecting from the data
86 //! event signal. When disabled, the forwarder will not process incoming data
87 //! events or forward outgoing messages.
88 virtual void disable() override;
89
90protected:
91 //! \brief Handles incoming data events from the exercise connection
92 //! \param data Reference to the received data event
93 //!
94 //! This method processes incoming data events from the exercise connection.
95 //! If the event contains VREngage messages (identified by DtVrEngageDatumParamId),
96 //! it extracts the messages from the data buffer and queues them for processing
97 //! by the message manager, excluding any messages that originated from this
98 //! application instance to prevent loops.
99 virtual void handleDataInteraction(const makVrfEvents::DtEvent& data);
100
101 //! \brief Sends a message through the network
102 //! \param msg Pointer to the message to send
103 //! \return Message processing result (HANDLED or NOT_HANDLED)
104 //!
105 //! This method bundles the message for efficient network transmission. If the
106 //! message was not previously forwarded (originatingApplicationId is 0), it is
107 //! added to an appropriate message bundle and tagged with this forwarder's ID.
108 //! The actual transmission occurs when flush() is called.
110
111 //! \brief Pointer to the communication manager for the exercise connection
112 //!
113 //! This communication manager is used to send outgoing messages through the
114 //! exercise connection and to receive incoming data events.
115 DtCommunicationManager* myCommunicationManager;
116
117 //! \brief Connection to the data event signal
118 //!
119 //! This connection is used to receive data events from the communication
120 //! manager's event manager. It is established in enable() and terminated
121 //! in disable().
122 boost::signals2::scoped_connection myDataInteractionConnection;
123};
124
125} // namespace makVre
virtual void flush() override
Flushes bundled messages to the network.
virtual void disable() override
Disables the network forwarder.
virtual void handleDataInteraction(const makVrfEvents::DtEvent &data)
Handles incoming data events from the exercise connection.
virtual makVre::DtVreMessageResult netSendMessage(makVre::DtVreMessage *msg) override
Sends a message through the network.
virtual ~DtExerciseConnNetworkForwarder() override
Virtual destructor.
DtCommunicationManager * myCommunicationManager
Pointer to the communication manager for the exercise connection.
Definition exerciseConnNetForwarder.h:115
boost::signals2::scoped_connection myDataInteractionConnection
Connection to the data event signal.
Definition exerciseConnNetForwarder.h:122
virtual bool enable() override
Enables the network forwarder.
DtExerciseConnNetworkForwarder(makVre::DtVreMessageFactory *factory, DtCommunicationManager *exerciseConn)
Constructor.
DtNetworkForwarder(DtVreMessageFactory *factory)
Constructor.
Factory for creating VREngage messages from serialized data.
Definition vreMessageFactory.h:48
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros for the VREngage Message Manager library.
#define MESSAGEMANAGER_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const int DtVrEngageDatumParamId
Parameter ID used to identify VREngage messages in data events.
Definition exerciseConnNetForwarder.h:36
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition vrfRemoteControlConnector.h:87
Defines base class for VREngage message network forwarding.
Defines the base class for all VREngage messages.