VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtNetworkForwarder Class Referenceabstract

Detailed Description

This class provides the foundation for forwarding VREngage messages across networks. It handles message bundling for efficient transmission and provides mechanisms for forwarding specific message types. Derived classes implement the actual network transport specifics by overriding the pure virtual flush() method and optionally the netSendMessage() method.

#include <networkForwarder.h>

Inheritance diagram for makVre::DtNetworkForwarder:
[legend]

Public Member Functions

 DtNetworkForwarder (DtVreMessageFactory *factory)
 
virtual ~DtNetworkForwarder ()
 
virtual void flush ()=0
 
virtual bool enable ()
 
virtual void disable ()
 
virtual void forwardEvents (const std::string &messageType)
 
virtual void stopForwardingEvents (const std::string &messageType)
 
virtual void setApplicationName (const std::string &applicationName)
 
virtual std::string applicationName ()
 

Static Public Member Functions

static int maxBundleSize ()
 

Protected Member Functions

virtual makVre::DtVreMessageResult netSendMessage (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleForwardMessage (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleStopForwardMessage (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleRequestForwardMessage (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleRequestStopForwardMessage (makVre::DtVreMessage *msg)
 

Protected Attributes

DtVreMessageFactorymyMessageFactory
 
UInt64 myId
 
std::vector< DtVreMessageBundle * > myMessageBundles
 
std::string myApplicationName
 

Constructor & Destructor Documentation

◆ DtNetworkForwarder()

makVre::DtNetworkForwarder::DtNetworkForwarder ( DtVreMessageFactory * factory)

Constructor.

Parameters
factoryPointer to the message factory for creating messages from raw data

Initializes a new network forwarder with the specified message factory. The message factory is used to create messages from incoming raw data. This constructor also initializes the first message bundle for outgoing messages.

◆ ~DtNetworkForwarder()

virtual makVre::DtNetworkForwarder::~DtNetworkForwarder ( )
virtual

Virtual destructor.

Calls disable() to unregister message handlers and performs cleanup.

Member Function Documentation

◆ flush()

virtual void makVre::DtNetworkForwarder::flush ( )
pure virtual

Flushes bundled messages to the network.

This pure virtual method must be implemented by derived classes to send accumulated message bundles over the network. Because messages are bundled for efficiency, this method should be called once per frame to ensure timely delivery of messages.

Note
This must be called once per frame to ensure messages are transmitted

Implemented in makVre::DtExerciseConnNetworkForwarder, and makVre::DtUdpNetworkForwarder.

◆ enable()

virtual bool makVre::DtNetworkForwarder::enable ( )
virtual

Enables the network forwarder.

Returns
True if the forwarder was successfully enabled

This method enables the network forwarder by registering message handlers for forwarding control messages. When enabled, the forwarder will process incoming control messages and forward outgoing messages of registered types. It also initializes the unique ID for this forwarder instance.

Reimplemented in makVre::DtExerciseConnNetworkForwarder, and makVre::DtUdpNetworkForwarder.

◆ disable()

virtual void makVre::DtNetworkForwarder::disable ( )
virtual

Disables the network forwarder.

This method disables the network forwarder by unregistering all message handlers. When disabled, the forwarder will not process incoming control messages or forward outgoing messages.

Reimplemented in makVre::DtExerciseConnNetworkForwarder, and makVre::DtUdpNetworkForwarder.

◆ forwardEvents()

virtual void makVre::DtNetworkForwarder::forwardEvents ( const std::string & messageType)
virtual

Starts forwarding messages of the specified type.

Parameters
messageTypeThe type of messages to forward

This method registers a handler for messages of the specified type to forward them over the network. Messages of this type will be bundled and sent when flush() is called.

◆ stopForwardingEvents()

virtual void makVre::DtNetworkForwarder::stopForwardingEvents ( const std::string & messageType)
virtual

Stops forwarding messages of the specified type.

Parameters
messageTypeThe type of messages to stop forwarding

This method unregisters the handler for messages of the specified type, stopping their forwarding over the network.

◆ setApplicationName()

virtual void makVre::DtNetworkForwarder::setApplicationName ( const std::string & applicationName)
virtual

Sets the application name for this network forwarder.

Parameters
applicationNameThe name to set for this application instance

This method sets the application name used to filter incoming forwarding request messages. Only requests targeting this application name will be processed.

References applicationName().

◆ applicationName()

virtual std::string makVre::DtNetworkForwarder::applicationName ( )
virtual

Gets the current application name.

Returns
The current application name

Returns the application name previously set with setApplicationName().

Referenced by setApplicationName().

◆ maxBundleSize()

static int makVre::DtNetworkForwarder::maxBundleSize ( )
static

Gets the maximum size of a message bundle.

Returns
Maximum bundle size in bytes

This static method returns the maximum size of a message bundle, which is calculated to fit within a single UDP packet including headers.

◆ netSendMessage()

virtual makVre::DtVreMessageResult makVre::DtNetworkForwarder::netSendMessage ( makVre::DtVreMessage * msg)
protectedvirtual

Sends a message through the network.

Parameters
msgPointer to the message to send
Returns
Message processing result (HANDLED or NOT_HANDLED)

This method bundles the message for efficient network transmission. If the message was not previously forwarded (originatingApplicationId is 0), it is added to an appropriate message bundle and tagged with this forwarder's ID. The actual transmission occurs when flush() is called.

Derived classes may override this method to implement custom message handling.

Reimplemented in makVre::DtExerciseConnNetworkForwarder.

◆ handleForwardMessage()

virtual makVre::DtVreMessageResult makVre::DtNetworkForwarder::handleForwardMessage ( makVre::DtVreMessage * msg)
protectedvirtual

Handles ForwardMessage control messages.

Parameters
msgPointer to the received message
Returns
Message processing result (HANDLED)

This method processes ForwardMessage control messages, which request forwarding of a specific message type. It calls forwardEvents() with the specified message type.

◆ handleStopForwardMessage()

virtual makVre::DtVreMessageResult makVre::DtNetworkForwarder::handleStopForwardMessage ( makVre::DtVreMessage * msg)
protectedvirtual

Handles StopForwardMessage control messages.

Parameters
msgPointer to the received message
Returns
Message processing result (HANDLED)

This method processes StopForwardMessage control messages, which request stopping forwarding of a specific message type. It calls stopForwardingEvents() with the specified message type.

◆ handleRequestForwardMessage()

virtual makVre::DtVreMessageResult makVre::DtNetworkForwarder::handleRequestForwardMessage ( makVre::DtVreMessage * msg)
protectedvirtual

Handles RequestForwardMessage control messages.

Parameters
msgPointer to the received message
Returns
Message processing result (HANDLED)

This method processes RequestForwardMessage control messages, which request forwarding of a specific message type from a specific host. If the request is for this host (matching applicationName), it calls forwardEvents().

◆ handleRequestStopForwardMessage()

virtual makVre::DtVreMessageResult makVre::DtNetworkForwarder::handleRequestStopForwardMessage ( makVre::DtVreMessage * msg)
protectedvirtual

Handles RequestStopForwardMessage control messages.

Parameters
msgPointer to the received message
Returns
Message processing result (HANDLED)

This method processes RequestStopForwardMessage control messages, which request stopping forwarding of a specific message type from a specific host. If the request is for this host (matching applicationName), it calls stopForwardingEvents().

Member Data Documentation

◆ myMessageFactory

DtVreMessageFactory* makVre::DtNetworkForwarder::myMessageFactory
protected

Pointer to the message factory for creating messages from raw data.

◆ myId

UInt64 makVre::DtNetworkForwarder::myId
protected

Unique identifier for this network forwarder instance.

This ID is used to tag outgoing messages to prevent processing loops when messages are received from the network.

◆ myMessageBundles

std::vector<DtVreMessageBundle*> makVre::DtNetworkForwarder::myMessageBundles
protected

Vector of message bundles for outgoing messages.

Messages are accumulated in these bundles until flush() is called. New bundles are created as needed when existing ones are full.

◆ myApplicationName

std::string makVre::DtNetworkForwarder::myApplicationName
protected

Application name for filtering forwarding request messages.

Only forwarding requests targeting this application name will be processed.


The documentation for this class was generated from the following file: