|
ORE Studio 0.0.4
|
Manages the lifecycle of the network client and IO context. More...
#include <ClientManager.hpp>
Inherits QObject.

Signals | |
| void | connected () |
| void | loggedIn () |
| void | disconnected () |
| void | reconnecting () |
| void | reconnected () |
| void | connectionError (const QString &message) |
| void | notificationReceived (const QString &eventType, const QDateTime ×tamp, const QStringList &entityIds) |
| Emitted when a notification is received from the server. | |
| void | recordingStarted (const QString &filePath) |
| Emitted when session recording starts. | |
| void | recordingStopped () |
| Emitted when session recording stops. | |
| void | streamingStarted () |
| Emitted when telemetry streaming starts. | |
| void | streamingStopped () |
| Emitted when telemetry streaming stops. | |
Public Member Functions | |
| ClientManager (std::shared_ptr< eventing::service::event_bus > event_bus, QObject *parent=nullptr) | |
| LoginResult | connect (const std::string &host, std::uint16_t port) |
| Connect to the server without logging in. | |
| LoginResult | login (const std::string &username, const std::string &password) |
| Login on an already connected client. | |
| LoginResult | connectAndLogin (const std::string &host, std::uint16_t port, const std::string &username, const std::string &password) |
| Connect to the server and perform login. | |
| LoginResult | testConnection (const std::string &host, std::uint16_t port, const std::string &username, const std::string &password) |
| Test a connection without affecting main client state. | |
| SignupResult | signup (const std::string &host, std::uint16_t port, const std::string &username, const std::string &email, const std::string &password) |
| Connect to the server and attempt signup. | |
| void | disconnect () |
| Logout the current user and disconnect from the server. | |
| bool | logout () |
| Logout the current user without disconnecting. | |
| bool | isConnected () const |
| Check if currently connected. | |
| bool | isAdmin () const |
| Check if the logged-in user has admin privileges. | |
| bool | isLoggedIn () const |
| Check if currently logged in. | |
| std::string | currentUsername () const |
| Get the current logged-in user's username. | |
| std::string | currentEmail () const |
| Get the current logged-in user's email. | |
| void | setCurrentEmail (const std::string &email) |
| Set the current logged-in user's email. | |
| std::optional< boost::uuids::uuid > | accountId () const |
| Get the account ID if logged in. | |
| std::string | serverAddress () const |
| Get the server address string. | |
| std::string | connectedHost () const |
| Get the connected server hostname. | |
| std::uint16_t | connectedPort () const |
| Get the connected server port. | |
| std::expected< comms::messaging::frame, ores::utility::serialization::error_code > | sendRequest (comms::messaging::frame request) |
| Send a request if connected. | |
| template<typename RequestType > requires comms::messaging::has_message_traits<RequestType> | |
| auto | process_request (RequestType request) |
| Process a request that does not require authentication. | |
| template<typename RequestType > requires comms::messaging::has_message_traits<RequestType> | |
| auto | process_authenticated_request (RequestType request) |
| Process a request that requires authentication. | |
| template<typename RequestType > requires comms::messaging::has_message_traits<RequestType> | |
| auto | process_admin_request (RequestType request) |
| Process a request that requires admin privileges. | |
| comms::net::client_session & | session () |
| Get the underlying client session. | |
| std::optional< SessionListResult > | listSessions (const boost::uuids::uuid &accountId, std::uint32_t limit=100, std::uint32_t offset=0) |
| List sessions for an account. | |
| std::optional< std::vector< iam::domain::session > > | getActiveSessions () |
| Get active sessions for the current user. | |
| std::shared_ptr< comms::net::client > | getClient () const |
| Get the current client (internal use only). | |
| boost::asio::any_io_executor | getExecutor () |
| Get the IO context executor. | |
| void | subscribeToEvent (const std::string &eventType) |
| Subscribe to server-push notifications for an event type. | |
| void | unsubscribeFromEvent (const std::string &eventType) |
| Unsubscribe from server-push notifications for an event type. | |
| void | setSupportedCompression (std::uint8_t compression) |
| Set the supported compression bitmask for client connections. | |
| bool | enableRecording (const std::filesystem::path &outputDirectory) |
| Enable session recording to the specified directory. | |
| void | disableRecording () |
| Disable session recording. | |
| bool | isRecording () const |
| Check if session recording is currently active. | |
| std::filesystem::path | recordingFilePath () const |
| Get the path to the current recording file. | |
| void | setRecordingDirectory (const std::filesystem::path &directory) |
| Set the recording output directory. | |
| std::filesystem::path | recordingDirectory () const |
| Get the current recording output directory. | |
| void | enableStreaming (const comms::service::telemetry_streaming_options &options) |
| Enable telemetry streaming to the server. | |
| void | disableStreaming () |
| Disable telemetry streaming. | |
| bool | isStreaming () const |
| Check if telemetry streaming is currently active. | |
| std::size_t | streamingPendingCount () const |
| Get the number of pending telemetry records. | |
| std::uint64_t | streamingTotalSent () const |
| Get total telemetry records sent successfully. | |
| std::uint64_t | streamingTotalDropped () const |
| Get total telemetry records dropped. | |
Manages the lifecycle of the network client and IO context.
Maintains a persistent IO context/thread while allowing the client connection to be established and torn down repeatedly. Signals changes in connection state to allow UI components to update accordingly without closing.
| LoginResult connect | ( | const std::string & | host, |
| std::uint16_t | port | ||
| ) |
Connect to the server without logging in.
Establishes a connection and checks bootstrap status. If the system is in bootstrap mode, returns with bootstrap_mode=true and the client remains connected (but not logged in). Otherwise, the client is connected and ready for a login() call.
| host | Server hostname |
| port | Server port |
| LoginResult login | ( | const std::string & | username, |
| const std::string & | password | ||
| ) |
Login on an already connected client.
Assumes the client is already connected via connect(). Sets up session info, stores credentials for reconnection, and emits the loggedIn signal.
| username | Login username |
| password | Login password |
| LoginResult connectAndLogin | ( | const std::string & | host, |
| std::uint16_t | port, | ||
| const std::string & | username, | ||
| const std::string & | password | ||
| ) |
Connect to the server and perform login.
Convenience method that calls connect() followed by login(). If bootstrap mode is detected, returns early with bootstrap_mode=true.
| host | Server hostname |
| port | Server port |
| username | Login username |
| password | Login password |
| LoginResult testConnection | ( | const std::string & | host, |
| std::uint16_t | port, | ||
| const std::string & | username, | ||
| const std::string & | password | ||
| ) |
Test a connection without affecting main client state.
Creates a temporary connection to verify credentials. Does not modify the main connection, emit signals, or publish events. Use this for testing saved connections from dialogs.
| host | Server hostname |
| port | Server port |
| username | Login username |
| password | Login password |
| SignupResult signup | ( | const std::string & | host, |
| std::uint16_t | port, | ||
| const std::string & | username, | ||
| const std::string & | email, | ||
| const std::string & | password | ||
| ) |
Connect to the server and attempt signup.
Creates a temporary connection to register a new user account. Does not establish a persistent connection or log in the user. The connection is closed after the signup attempt completes.
| host | Server hostname |
| port | Server port |
| username | Desired username |
| User's email address | |
| password | Desired password |
| void disconnect | ( | ) |
Logout the current user and disconnect from the server.
Sends a logout request to mark the user as offline before disconnecting.
| bool logout | ( | ) |
Logout the current user without disconnecting.
Sends a logout request to the server to mark the user as offline.
| bool isAdmin | ( | ) | const |
Check if the logged-in user has admin privileges.
| bool isLoggedIn | ( | ) | const |
Check if currently logged in.
| std::string currentUsername | ( | ) | const |
Get the current logged-in user's username.
| std::string currentEmail | ( | ) | const |
Get the current logged-in user's email.
| void setCurrentEmail | ( | const std::string & | ) |
Set the current logged-in user's email.
Used after successful email update to keep local state in sync.
| std::optional< boost::uuids::uuid > accountId | ( | ) | const |
Get the account ID if logged in.
| std::string serverAddress | ( | ) | const |
Get the server address string.
| std::string connectedHost | ( | ) | const |
Get the connected server hostname.
| std::uint16_t connectedPort | ( | ) | const |
Get the connected server port.
| std::expected< comms::messaging::frame, ores::utility::serialization::error_code > sendRequest | ( | comms::messaging::frame | request | ) |
Send a request if connected.
| request | The request frame to send |
| auto process_request | ( | RequestType | request | ) |
Process a request that does not require authentication.
Uses message_traits to automatically determine the response type.
| RequestType | Request message type (must have message_traits) |
| request | The request to send |
| auto process_authenticated_request | ( | RequestType | request | ) |
Process a request that requires authentication.
Checks if logged in before sending.
| RequestType | Request message type (must have message_traits) |
| request | The request to send |
| auto process_admin_request | ( | RequestType | request | ) |
Process a request that requires admin privileges.
Checks if logged in as admin before sending.
| RequestType | Request message type (must have message_traits) |
| request | The request to send |
| comms::net::client_session & session | ( | ) |
Get the underlying client session.
Provides access to the session for advanced use cases.
| std::optional< SessionListResult > listSessions | ( | const boost::uuids::uuid & | accountId, |
| std::uint32_t | limit = 100, |
||
| std::uint32_t | offset = 0 |
||
| ) |
List sessions for an account.
| accountId | The account UUID (nil for own sessions) |
| limit | Maximum sessions to return |
| offset | Pagination offset |
| std::optional< std::vector< iam::domain::session > > getActiveSessions | ( | ) |
Get active sessions for the current user.
| void subscribeToEvent | ( | const std::string & | eventType | ) |
Subscribe to server-push notifications for an event type.
This method is non-blocking - the subscription request is sent asynchronously and any errors are logged.
| eventType | The event type to subscribe to (e.g., "ores.refdata.currency_changed_event") |
| void unsubscribeFromEvent | ( | const std::string & | eventType | ) |
Unsubscribe from server-push notifications for an event type.
This method is non-blocking - the unsubscription request is sent asynchronously and any errors are logged.
| eventType | The event type to unsubscribe from |

| void setSupportedCompression | ( | std::uint8_t | compression | ) |
Set the supported compression bitmask for client connections.
Should be called before connectAndLogin(). The value is used when creating client_options for the handshake negotiation.
| compression | Bitmask of supported compression types (0 = disabled) |
| bool enableRecording | ( | const std::filesystem::path & | outputDirectory | ) |
Enable session recording to the specified directory.
Creates a new session recording file in the specified directory. Recording can be enabled before or after connecting. If enabled before connecting, recording will start when the connection is established.
| outputDirectory | Directory where session files will be created |
| void disableRecording | ( | ) |
Disable session recording.
Stops recording and closes the session file. Safe to call when not recording.
| std::filesystem::path recordingFilePath | ( | ) | const |
Get the path to the current recording file.
| void setRecordingDirectory | ( | const std::filesystem::path & | directory | ) |
Set the recording output directory.
This directory is used when enableRecording() is called without a directory argument, or when auto-recording is enabled.
| directory | The default output directory for recordings |
| void enableStreaming | ( | const comms::service::telemetry_streaming_options & | options | ) |
Enable telemetry streaming to the server.
Streaming can be enabled before or after connecting. If enabled before connecting, streaming will start when the connection is established.
| options | Streaming options (batch size, flush interval, etc.) |
| void disableStreaming | ( | ) |
Disable telemetry streaming.
Stops streaming and flushes any pending logs. Safe to call when not streaming.
| std::size_t streamingPendingCount | ( | ) | const |
Get the number of pending telemetry records.
|
signal |
Emitted when a notification is received from the server.
| eventType | The event type name (e.g., "ores.refdata.currency_changed_event") |
| timestamp | When the event occurred |
| entityIds | Identifiers of entities that changed (e.g., currency ISO codes) |
|
signal |
Emitted when session recording starts.
| filePath | Path to the recording file |