VR-Engage  2.2
Loading...
Searching...
No Matches
networkConnectedState.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file networkConnectedState.h
7//! \brief Defines the connected state for networked simulation in VR-Engage
8//!
9//! This file contains the DtNetworkConnectedState class which manages the
10//! application state when VR-Engage is connected to a networked simulation.
11//! It handles loading resources, processing network events, and transitioning
12//! between role selection and engagement states.
13
14#pragma once
15
17
19
21
22namespace makVre
23{
24//! \brief Forward declaration of the loading page class
26
27//! \brief Application state for network-connected operation
28//!
29//! DtNetworkConnectedState represents the application state when VR-Engage
30//! is connected to a networked simulation. It manages resource loading,
31//! network communications, and transitions between sub-states like role
32//! selection and entity engagement. This state contains most of the active
33//! gameplay functionality of the application.
35{
36public:
37 //! \brief Constructor
38 //! \param app Reference to the player station application
39 //!
40 //! Creates a new network connected state associated with the given application.
41 //! This state is typically entered after a successful network connection.
43
44 //! \brief Virtual destructor
45 //!
46 //! Ensures proper cleanup of network connected state resources.
47 virtual ~DtNetworkConnectedState() override;
48
49 //! \brief Called when the state is entered
50 //!
51 //! Initializes network-related resources, registers message handlers,
52 //! and begins loading simulation resources like model sets and entity
53 //! definitions. This is called when a network connection is established.
54 virtual void onEnter() override;
55
56 //! \brief Called when the state is exited
57 //!
58 //! Cleans up resources, disconnects from the network, and unregisters
59 //! message handlers. This is called when disconnecting from the network
60 //! or shutting down the application.
61 virtual void onExit() override;
62
63 //! \brief Called when another state is pushed on top of this one
64 //!
65 //! Handles adjustments needed when this state is covered by another state
66 //! on the stack, such as pausing certain network operations or UI updates.
67 virtual void onStacked() override;
68
69 //! \brief Called when the state becomes the topmost state again
70 //!
71 //! Restores functionality when this state is exposed after another state
72 //! has been popped from the stack, resuming network operations and updates.
73 virtual void onExposed() override;
74
75 //! \brief Updates the state each frame
76 //! \param dt Time in seconds since the last update
77 //!
78 //! Handles per-frame processing in the connected state, including
79 //! monitoring resource loading progress, processing network events,
80 //! and updating UI elements as needed.
81 virtual void tick(double dt) override;
82
83 //! \brief Invokes Vortex debug callbacks
84 //!
85 //! Used for debugging physics simulation (Vortex) related functionality.
86 //! This is typically only called during development and testing.
87 virtual void debugVortexCallback();
88
89protected:
90 //! \brief Message handlers
91 //! @{
92
93 //! \brief Handles messages requesting to stop the network connection
94 //! \param msg Pointer to the stop connection message
95 //! \return Message handling result
96 //!
97 //! Processes requests to voluntarily disconnect from the network,
98 //! typically initiated by the user or another part of the application.
100
101 //! \brief Handles network disconnection messages
102 //! \param msg Pointer to the network disconnected message
103 //! \return Message handling result
104 //!
105 //! Processes notifications that the network connection has been lost,
106 //! transitioning to an appropriate state to handle the disconnection.
108
109 //! \brief Handles SMS load completion messages
110 //! \param msg Pointer to the SMS load complete message
111 //! \return Message handling result
112 //!
113 //! Processes notifications that Simulation Model Sets (SMS) have finished
114 //! loading, updating the application state accordingly.
116
117 //! \brief Handles visual model definitions loaded messages
118 //! \param msg Pointer to the visual model definitions loaded message
119 //! \return Message handling result
120 //!
121 //! Processes notifications that visual model definitions have finished
122 //! loading, which is a prerequisite for proper entity visualization.
124 //! @}
125
126 //! \brief Name of the network driver being used
127 //!
128 //! Identifies which network protocol driver (e.g., DIS, HLA) is currently active.
129 std::string myDriverName;
130
131 //! \brief Shared pointer to the loading page UI
132 //!
133 //! Provides the user interface for displaying loading progress
134 //! while resources are being loaded in the background.
135 std::shared_ptr<DtVreLoadingPage> myLoadingPage;
136
137 //! \brief Bitmask tracking the status of SMS resource loading
138 //!
139 //! Used to track which specific resource types have completed loading,
140 //! allowing the application to determine when all required resources are ready.
142};
143
144} // namespace makVre
virtual void debugVortexCallback()
Invokes Vortex debug callbacks.
std::shared_ptr< DtVreLoadingPage > myLoadingPage
Shared pointer to the loading page UI.
Definition networkConnectedState.h:135
virtual DtVreMessageResult handleVisualModelDefinitionsLoaded(DtVreMessage *msg)
Handles visual model definitions loaded messages.
virtual DtVreMessageResult handleSmsLoadComplete(DtVreMessage *msg)
Handles SMS load completion messages.
virtual ~DtNetworkConnectedState() override
Virtual destructor.
int mySmsLoadStatusBits
Bitmask tracking the status of SMS resource loading.
Definition networkConnectedState.h:141
virtual void onStacked() override
Called when another state is pushed on top of this one.
virtual void tick(double dt) override
Updates the state each frame.
virtual void onExposed() override
Called when the state becomes the topmost state again.
DtNetworkConnectedState(DtPlayerStationApp &app)
Constructor.
std::string myDriverName
Name of the network driver being used.
Definition networkConnectedState.h:129
virtual void onEnter() override
Called when the state is entered.
virtual DtVreMessageResult handleNetworkDisconnected(DtVreMessage *msg)
Handles network disconnection messages.
virtual void onExit() override
Called when the state is exited.
virtual DtVreMessageResult handleStopConnection(DtVreMessage *msg)
Message handlers.
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:163
DtPlayerStationApp & app() const
Gets a reference to the player station application.
DtPlayerStationState(DtPlayerStationApp &app, std::string stateType)
Constructor.
UI component for displaying loading progress in VR-Engage.
Definition vreLoadingPage.h:39
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines base classes for the VR-Engage state management system.
Defines the base class for all VREngage messages.