VR-Engage  2.3
Loading...
Searching...
No Matches
joinedSessionState.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file joinedSessionState.h
7//! \brief Defines the state for a joined simulation session in VR-Engage
8//!
9//! This file contains the DtJoinedSessionState class which manages the application
10//! state when the user has joined an existing simulation session. It handles
11//! session status monitoring, UI updates, and transitions to other states.
12
13#pragma once
14
16
19
21
22#include <set>
23#include <string>
24
25// #include <memory>
26
27class QProcess;
28
29namespace makVre
30{
31//! \brief Forward declaration of the session load data message class
33
34//! \brief Enumeration of session types in VR-Engage
35//!
36//! Defines the different types of sessions that can be active in the application,
37//! indicating how the session was created or accessed.
38enum class DtSessionType
39{
40 HOSTED_SESSION = 1, //!< Session created and hosted by this instance
41 UNHOSTED_SESSION, //!< Local session not accessible by other users
42 JOINED_SESSION, //!< Session joined from another host
43 UNKNOWN_SESSION = 100 //!< Session type could not be determined
44};
45
46//! \brief Application state for an active joined simulation session
47//!
48//! DtJoinedSessionState represents the application state when the user has
49//! successfully joined an existing simulation session. It manages the connection
50//! to the session, monitors session status, and provides UI controls for session
51//! management. This state is typically entered after connecting to a network
52//! and selecting a session to join.
54{
55public:
56 //! \brief Constructor
57 //! \param app Reference to the player station application
58 //!
59 //! Creates a new joined session state associated with the given application.
60 //! This state is entered when a user successfully joins a simulation session.
62
63 //! \brief Virtual destructor
64 //!
65 //! Ensures proper cleanup of resources used by the joined session state.
66 virtual ~DtJoinedSessionState() override;
67
68 //! \brief Called when the state is entered
69 //! \param args Pointer to arguments from the previous state
70 //!
71 //! Sets up the joined session, registers message handlers, and initializes
72 //! the UI. This is called when the user first joins a simulation session.
73 virtual void onEnter(const DtPlayerStationStateArgs* args) override;
74
75 //! \brief Called when the state is exited
76 //!
77 //! Cleans up resources, unregisters message handlers, and performs any
78 //! necessary session disconnection operations.
79 virtual void onExit() override;
80
81 //! \brief Updates the state each frame
82 //! \param dt Time in seconds since the last update
83 //!
84 //! Handles per-frame updates for the joined session, including monitoring
85 //! session status and updating UI elements.
86 virtual void tick(double dt) override;
87
88 //! \brief Gets the current session type
89 //! \return Type of the current session
90 //!
91 //! Retrieves the type of the current session (e.g., hosted, unhosted, joined).
92 //! This can be used to determine appropriate behavior based on session type.
94
95protected:
96 //! \brief Message handlers
97 //! @{
98
99 //! \brief Handles session status messages
100 //! \param msg Pointer to the session status message
101 //! \return Message handling result
102 //!
103 //! Processes messages about changes to the VRF session status,
104 //! updating the application state accordingly.
106
107 //! \brief Handles choose session button click messages
108 //! \param msg Pointer to the button click message
109 //! \return Message handling result
110 //!
111 //! Processes messages generated when the user clicks the button
112 //! to choose a different session, typically exiting the current session.
114
115 //! \brief Handles application mode update messages
116 //! \param msg Pointer to the app mode update message
117 //! \return Message handling result
118 //!
119 //! Processes messages about changes to the application mode,
120 //! adjusting the session state accordingly.
122 //! @}
123
124 //! \brief Updates UI cutout controls based on a specific context
125 //! \param context Context identifier to determine which controls to show/hide
126 //!
127 //! Adjusts the visibility and state of UI controls in the cutout area
128 //! based on the specified context. This allows for dynamic UI adjustments
129 //! appropriate to the current session state and user activity.
130 virtual void updateUICutoutControls(const std::string& context);
131
132 //! \brief ImGui callback that draws remote debugger controls in the Sim debug tab
133 //!
134 //! Provides buttons for starting/stopping the remote debugger application and
135 //! connecting/disconnecting from the sim backend.
137
138 //! \brief Session load data message
139 //!
140 //! Contains information about the session that was loaded,
141 //! including configuration settings and connection details.
142 std::shared_ptr<SessionLoadDataMessage> myLoadData;
143
144 //! \brief Type of the current session
145 //!
146 //! Identifies whether this is a hosted, unhosted, or joined session.
148
149 //! \brief Handle root for UI resources.
150 //! \vreAttrKey{ui}
152
153 //! \brief Whether the remote debugger process has been started
155 //! \brief Set of sim address keys currently connected to the remote debugger
156 std::set<std::string> myConnectedDebuggers;
157 //! \brief The remote debugger process managed by QProcess
159
160 //! \brief Whether the Tracy profiler process has been started
162 //! \brief Set of sim address keys currently enabled for Tracy profiling
163 std::set<std::string> myEnabledTracySims;
164 //! \brief The Tracy profiler process managed by QProcess
165 QProcess* myTracyProcess;
166};
167
168} // namespace makVre
Provides handle classes for safe access to attributes.
Handle class for safe access to attributes.
Definition attributeHandle.h:30
virtual DtVreMessageResult handleChooseSessionButtonClicked(DtVreMessage *msg)
Handles choose session button click messages.
virtual ~DtJoinedSessionState() override
Virtual destructor.
virtual void onEnter(const DtPlayerStationStateArgs *args) override
Called when the state is entered.
std::set< std::string > myEnabledTracySims
Set of sim address keys currently enabled for Tracy profiling.
Definition joinedSessionState.h:163
DtAttributeHandle myUIAttr
Handle root for UI resources.
Definition joinedSessionState.h:151
std::set< std::string > myConnectedDebuggers
Set of sim address keys currently connected to the remote debugger.
Definition joinedSessionState.h:156
virtual DtVreMessageResult handleVrfSessionStatus(DtVreMessage *msg)
Message handlers.
virtual void updateUICutoutControls(const std::string &context)
Updates UI cutout controls based on a specific context.
virtual void tick(double dt) override
Updates the state each frame.
virtual void remoteDebuggerCallback()
ImGui callback that draws remote debugger controls in the Sim debug tab.
QProcess * myDebuggerProcess
The remote debugger process managed by QProcess.
Definition joinedSessionState.h:158
bool myRemoteDebuggerStarted
Whether the remote debugger process has been started.
Definition joinedSessionState.h:154
virtual void onExit() override
Called when the state is exited.
DtSessionType mySessionType
Type of the current session.
Definition joinedSessionState.h:147
QProcess * myTracyProcess
The Tracy profiler process managed by QProcess.
Definition joinedSessionState.h:165
DtJoinedSessionState(DtPlayerStationApp &app)
Constructor.
virtual DtVreMessageResult handleAppModeUpdated(DtVreMessage *msg)
Handles application mode update messages.
virtual DtSessionType getSessionType()
Gets the current session type.
std::shared_ptr< SessionLoadDataMessage > myLoadData
Session load data message.
Definition joinedSessionState.h:142
bool myTracyStarted
Whether the Tracy profiler process has been started.
Definition joinedSessionState.h:161
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:155
Class for passing arguments during state transitions.
Definition playerStationState.h:47
DtPlayerStationApp & app() const
Gets a reference to the player station application.
DtPlayerStationState(DtPlayerStationApp &app, std::string stateType)
Constructor.
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Used to pass data between application states.
Definition sessionLoadData.h:33
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
!
Definition glsVreMessageUtil.h:50
DtSessionType
Enumeration of session types in VR-Engage.
Definition joinedSessionState.h:39
@ UNHOSTED_SESSION
Local session not accessible by other users.
Definition joinedSessionState.h:41
@ UNKNOWN_SESSION
Session type could not be determined.
Definition joinedSessionState.h:43
@ JOINED_SESSION
Session joined from another host.
Definition joinedSessionState.h:42
@ HOSTED_SESSION
Session created and hosted by this instance.
Definition joinedSessionState.h:40
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.