VR-Engage  2.2
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
20// #include <memory>
21
22namespace makVre
23{
24//! \brief Forward declaration of the session load data message class
26
27//! \brief Enumeration of session types in VR-Engage
28//!
29//! Defines the different types of sessions that can be active in the application,
30//! indicating how the session was created or accessed.
31enum class DtSessionType
32{
33 HOSTED_SESSION = 1, //!< Session created and hosted by this instance
34 UNHOSTED_SESSION, //!< Local session not accessible by other users
35 JOINED_SESSION, //!< Session joined from another host
36 UNKNOWN_SESSION = 100 //!< Session type could not be determined
37};
38
39//! \brief Application state for an active joined simulation session
40//!
41//! DtJoinedSessionState represents the application state when the user has
42//! successfully joined an existing simulation session. It manages the connection
43//! to the session, monitors session status, and provides UI controls for session
44//! management. This state is typically entered after connecting to a network
45//! and selecting a session to join.
47{
48public:
49 //! \brief Constructor
50 //! \param app Reference to the player station application
51 //!
52 //! Creates a new joined session state associated with the given application.
53 //! This state is entered when a user successfully joins a simulation session.
55
56 //! \brief Virtual destructor
57 //!
58 //! Ensures proper cleanup of resources used by the joined session state.
59 virtual ~DtJoinedSessionState() override;
60
61 //! \brief Called when the state is entered
62 //! \param args Pointer to arguments from the previous state
63 //!
64 //! Sets up the joined session, registers message handlers, and initializes
65 //! the UI. This is called when the user first joins a simulation session.
66 virtual void onEnter(const DtPlayerStationStateArgs* args) override;
67
68 //! \brief Called when the state is exited
69 //!
70 //! Cleans up resources, unregisters message handlers, and performs any
71 //! necessary session disconnection operations.
72 virtual void onExit() override;
73
74 //! \brief Updates the state each frame
75 //! \param dt Time in seconds since the last update
76 //!
77 //! Handles per-frame updates for the joined session, including monitoring
78 //! session status and updating UI elements.
79 virtual void tick(double dt) override;
80
81 //! \brief Gets the current session type
82 //! \return Type of the current session
83 //!
84 //! Retrieves the type of the current session (e.g., hosted, unhosted, joined).
85 //! This can be used to determine appropriate behavior based on session type.
87
88protected:
89 //! \brief Message handlers
90 //! @{
91
92 //! \brief Handles session status messages
93 //! \param msg Pointer to the session status message
94 //! \return Message handling result
95 //!
96 //! Processes messages about changes to the VRF session status,
97 //! updating the application state accordingly.
99
100 //! \brief Handles choose session button click messages
101 //! \param msg Pointer to the button click message
102 //! \return Message handling result
103 //!
104 //! Processes messages generated when the user clicks the button
105 //! to choose a different session, typically exiting the current session.
107
108 //! \brief Handles application mode update messages
109 //! \param msg Pointer to the app mode update message
110 //! \return Message handling result
111 //!
112 //! Processes messages about changes to the application mode,
113 //! adjusting the session state accordingly.
115 //! @}
116
117 //! \brief Updates UI cutout controls based on a specific context
118 //! \param context Context identifier to determine which controls to show/hide
119 //!
120 //! Adjusts the visibility and state of UI controls in the cutout area
121 //! based on the specified context. This allows for dynamic UI adjustments
122 //! appropriate to the current session state and user activity.
123 virtual void updateUICutoutControls(const std::string& context);
124
125 //! \brief Session load data message
126 //!
127 //! Contains information about the session that was loaded,
128 //! including configuration settings and connection details.
129 std::shared_ptr<SessionLoadDataMessage> myLoadData;
130
131 //! \brief Type of the current session
132 //!
133 //! Identifies whether this is a hosted, unhosted, or joined session.
135};
136
137} // namespace makVre
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.
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 onExit() override
Called when the state is exited.
DtSessionType mySessionType
Type of the current session.
Definition joinedSessionState.h:134
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:129
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:163
Class for passing arguments during state transitions.
Definition playerStationState.h:45
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
Definition sessionLoadData.h:29
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
DtSessionType
Enumeration of session types in VR-Engage.
Definition joinedSessionState.h:32
@ UNHOSTED_SESSION
Local session not accessible by other users.
Definition joinedSessionState.h:34
@ UNKNOWN_SESSION
Session type could not be determined.
Definition joinedSessionState.h:36
@ JOINED_SESSION
Session joined from another host.
Definition joinedSessionState.h:35
@ HOSTED_SESSION
Session created and hosted by this instance.
Definition joinedSessionState.h:33
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.