VR-Engage  2.2
Loading...
Searching...
No Matches
waitingForHostState.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file waitingForHostState.h
7//! \brief Defines a player station state for waiting to join a hosted session
8//!
9//! The DtWaitingForHostState class implements a state that displays a waiting screen
10//! while monitoring for an available hosted session to join. It handles session status
11//! updates, can start an ownship simulation if configured, and transitions to the
12//! joined session state when a host becomes available.
13
14#pragma once
15
17
19
21
23
24namespace makVre
25{
26//! Forward declaration of the waiting page UI class
28
29//! \brief A state that displays a waiting screen while monitoring for a hosted session to join
30//!
31//! This state is activated when the user chooses to join a session. It displays
32//! a waiting page and monitors for session status updates. When a hosted session
33//! with a terrain becomes available, it transitions to the joined session state.
34//! If configured, it can also start an ownship simulation.
36{
37public:
38 //! \brief Constructor for the waiting for host state
39 //! \param app Reference to the player station application
40 //!
41 //! Initializes the state with a reference to the application and sets default values.
43
44 //! \brief Virtual destructor
45 virtual ~DtWaitingForHostState() override;
46
47 //! \brief Called when entering this state
48 //! \param args Pointer to arguments containing a VrfSessionStatusMessage
49 //!
50 //! Sets up the waiting page UI, registers message handlers, and checks the
51 //! startup configuration. If configured, it may start an ownship simulation.
52 //! It also determines if the application is in join-only mode based on the
53 //! application mode or startup configuration.
54 virtual void onEnter(const DtPlayerStationStateArgs* args) override;
55
56 //! \brief Called when exiting this state
57 //!
58 //! Removes message handlers and closes the waiting page UI.
59 virtual void onExit() override;
60
61 //! \brief Called every frame to update the state
62 //! \param dt Time elapsed since the last frame in seconds
63 //!
64 //! Performs periodic updates for this state, currently minimal implementation.
65 virtual void tick(double dt) override;
66
67protected:
68 //! \brief Handles session status messages
69 //! \param msg The session status message
70 //! \return Message handling result (HANDLED or IGNORED)
71 //!
72 //! Processes session status updates. If a terrain is available, creates a
73 //! SessionLoadDataMessage and transitions to the JOINED_SESSION_STATE. If no
74 //! terrain is available and not in join-only mode, transitions back to the
75 //! SESSION_MENU_STATE and stops the ownship simulation if it was started.
77
78 //! \brief Starts the ownship simulation backend
79 //! \return True if the ownship simulation was started, false if it was already running
80 //!
81 //! This method initiates the ownship simulation backend by creating and queuing a
82 //! StartBackendMessage. It checks whether the simulation has already been started
83 //! by examining the "ownshipSimStarted" attribute in the application attribute store.
84 //! If the simulation is not running, it:
85 //! - Creates a StartBackendMessage with appropriate host/ownship settings
86 //! - Displays a notification with the simulation address
87 //! - Sets the "ownshipSimStarted" attribute to true
88 //!
89 //! \note This method will not start the simulation if it has already been started
90 //! \note The ownship mode is determined by checking if a VRF host exists
91 virtual bool startOwnship();
92
93 //! \brief Reference to the waiting page UI component
94 std::shared_ptr<DtVreWaitingPage> myWaitingPage;
95
96 //! \brief Flag indicating if the application is in join-only mode
97 //!
98 //! When true, the application will only attempt to join sessions and will not
99 //! return to the session menu if no host is available.
101
102 //! \brief Cached copy of the session status message
103 //!
104 //! Contains information about the current session status, including whether
105 //! the session is hosted and what terrain is being used.
106 std::shared_ptr<VrfSessionStatusMessage> mySessionData;
107};
108
109} // namespace makVre
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
Waiting page UI component for VR-Engage.
Definition vreWaitingPage.h:35
std::shared_ptr< VrfSessionStatusMessage > mySessionData
Cached copy of the session status message.
Definition waitingForHostState.h:106
bool myJoinOnlyMode
Flag indicating if the application is in join-only mode.
Definition waitingForHostState.h:100
virtual DtVreMessageResult handleVrfSessionStatus(DtVreMessage *msg)
Handles session status messages.
std::shared_ptr< DtVreWaitingPage > myWaitingPage
Reference to the waiting page UI component.
Definition waitingForHostState.h:94
virtual void onEnter(const DtPlayerStationStateArgs *args) override
Called when entering this state.
virtual void tick(double dt) override
Called every frame to update the state.
virtual ~DtWaitingForHostState() override
Virtual destructor.
DtWaitingForHostState(DtPlayerStationApp &app)
Constructor for the waiting for host state.
virtual void onExit() override
Called when exiting this state.
virtual bool startOwnship()
Starts the ownship simulation backend.
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.