|
ORE Studio 0.0.4
|
Client-side session manager providing auth-aware request handling. More...
#include <client_session.hpp>

Public Member Functions | |
| client_session (const client_session &)=delete | |
| client_session & | operator= (const client_session &)=delete |
| client_session (client_session &&)=delete | |
| client_session & | operator= (client_session &&)=delete |
| std::expected< void, session_error > | connect (client_options options) |
| Connect to the server. | |
| std::expected< void, session_error > | attach_client (std::shared_ptr< client > external_client) |
| Attach an external client to this session. | |
| void | disconnect () |
| Disconnect from the server. | |
| void | detach_client () |
| Detach an externally-attached client. | |
| bool | is_connected () const noexcept |
| Check if connected to server. | |
| std::shared_ptr< client > | get_client () const noexcept |
| Get the underlying client. | |
| bool | is_logged_in () const noexcept |
| Check if logged in. | |
| void | set_session_info (client_session_info info) |
| Set session info after successful login. | |
| void | clear_session_info () noexcept |
| Clear session info on logout. | |
| const std::optional< client_session_info > & | session_info () const noexcept |
| Get current session info if logged in. | |
| std::string | username () const noexcept |
| Get the current username if logged in. | |
| std::string | email () const noexcept |
| Get the current email if logged in. | |
| void | set_email (const std::string &email) |
| Set the current email. | |
| std::optional< boost::uuids::uuid > | account_id () const noexcept |
| Get the account ID if logged in. | |
| template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType> | |
| std::expected< ResponseType, session_error > | process_request (RequestType request) |
| Process a request that does not require authentication. | |
| template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType> | |
| std::expected< ResponseType, session_error > | process_authenticated_request (RequestType request) |
| Process a request that requires authentication. | |
| template<Serializable RequestType, Deserializable ResponseType, messaging::message_type RequestMsgType> | |
| std::expected< ResponseType, session_error > | process_admin_request (RequestType request) |
| Process a request that requires admin privileges. | |
| template<typename RequestType > requires messaging::has_message_traits<RequestType> | |
| std::expected< typename messaging::message_traits< RequestType >::response_type, session_error > | process_request (RequestType request) |
| Process a request using message_traits (does not require auth). | |
| template<typename RequestType > requires messaging::has_message_traits<RequestType> | |
| std::expected< typename messaging::message_traits< RequestType >::response_type, session_error > | process_authenticated_request (RequestType request) |
| Process a request using message_traits (requires authentication). | |
| template<typename RequestType > requires messaging::has_message_traits<RequestType> | |
| std::expected< typename messaging::message_traits< RequestType >::response_type, session_error > | process_admin_request (RequestType request) |
| Process a request using message_traits (requires admin). | |
| bool | subscribe (const std::string &event_type) |
| Subscribe to notifications for an event type. | |
| bool | unsubscribe (const std::string &event_type) |
| Unsubscribe from notifications for an event type. | |
| bool | is_subscribed (const std::string &event_type) const |
| Check if currently subscribed to an event type. | |
| std::set< std::string > | get_subscriptions () const |
| Get the set of currently subscribed event types. | |
| std::vector< pending_notification > | take_pending_notifications () |
| Get all pending notifications and clear the queue. | |
| bool | has_pending_notifications () const |
| Check if there are any pending notifications. | |
| void | set_notification_callback (notification_callback_t callback) |
| Set an external notification callback. | |
Client-side session manager providing auth-aware request handling.
This class wraps a net::client and provides:
Designed to be shared between ores.comms.shell and ores.qt clients.
| std::expected< void, session_error > connect | ( | client_options | options | ) |
Connect to the server.
Creates a new client internally and connects. Use this for standalone usage (e.g., in ores.comms.shell).
| options | Connection options |

| std::expected< void, session_error > attach_client | ( | std::shared_ptr< client > | external_client | ) |
Attach an external client to this session.
Use this when the client lifecycle is managed externally (e.g., in ores.qt where ClientManager owns the client). The session will use the provided client for requests but will not manage its lifecycle.
| external_client | The client to attach (must be connected) |
| void disconnect | ( | ) |
Disconnect from the server.
For internally-created clients: disconnects and destroys the client. For externally-attached clients: detaches without disconnecting (caller is responsible for client lifecycle).

| void detach_client | ( | ) |
Detach an externally-attached client.
Clears session state and event adapter, but does not disconnect the client. Use this when transferring client ownership or when the external client will be reused.

|
noexcept |
Get the underlying client.
Provides access to the client for advanced use cases like telemetry streaming. Returns nullptr if not connected.

| void set_session_info | ( | client_session_info | info | ) |
Set session info after successful login.
Called by the application layer after processing a login response.
| info | Session information from login response |

|
noexcept |
Clear session info on logout.
Called by the application layer after logout or disconnect.

| void set_email | ( | const std::string & | ) |
Set the current email.
Used after successful email update to keep local state in sync.

| std::expected< ResponseType, session_error > process_request | ( | RequestType | request | ) |
Process a request that does not require authentication.
Use this for messages like bootstrap_status_request that don't need login.
| RequestType | Request message type (must be Serializable) |
| ResponseType | Response message type (must be Deserializable) |
| RequestMsgType | The message_type enum value for the request |
| request | The request to send |

| std::expected< ResponseType, session_error > process_authenticated_request | ( | RequestType | request | ) |
Process a request that requires authentication.
Checks if logged in before sending. Use this for most requests.
| RequestType | Request message type (must be Serializable) |
| ResponseType | Response message type (must be Deserializable) |
| RequestMsgType | The message_type enum value for the request |
| request | The request to send |

| std::expected< ResponseType, session_error > process_admin_request | ( | RequestType | request | ) |
Process a request that requires admin privileges.
| RequestType | Request message type (must be Serializable) |
| ResponseType | Response message type (must be Deserializable) |
| RequestMsgType | The message_type enum value for the request |
| request | The request to send |

| std::expected< typename messaging::message_traits< RequestType >::response_type, session_error > process_request | ( | RequestType | request | ) |
Process a request using message_traits (does not require auth).
Uses message_traits to automatically determine the response type and message_type enum value from the request type.
| RequestType | Request message type (must have message_traits) |
| request | The request to send |
| std::expected< typename messaging::message_traits< RequestType >::response_type, session_error > process_authenticated_request | ( | RequestType | request | ) |
Process a request using message_traits (requires authentication).
| RequestType | Request message type (must have message_traits) |
| request | The request to send |
| std::expected< typename messaging::message_traits< RequestType >::response_type, session_error > process_admin_request | ( | RequestType | request | ) |
Process a request using message_traits (requires admin).
| RequestType | Request message type (must have message_traits) |
| request | The request to send |
| bool subscribe | ( | const std::string & | event_type | ) |
Subscribe to notifications for an event type.
Delegates to remote_event_adapter to send a SUBSCRIBE protocol message. Received notifications are queued for retrieval via take_pending_notifications().
| event_type | The fully qualified event type name (e.g., "ores.refdata.currency_changed") |

| bool unsubscribe | ( | const std::string & | event_type | ) |
Unsubscribe from notifications for an event type.
Delegates to remote_event_adapter to send an UNSUBSCRIBE protocol message.
| event_type | The fully qualified event type name |

| bool is_subscribed | ( | const std::string & | event_type | ) | const |
Check if currently subscribed to an event type.
| event_type | The event type to check |

| std::set< std::string > get_subscriptions | ( | ) | const |
Get the set of currently subscribed event types.

| std::vector< pending_notification > take_pending_notifications | ( | ) |
Get all pending notifications and clear the queue.
Returns notifications in the order they were received. The internal queue is cleared after this call.

| bool has_pending_notifications | ( | ) | const |
Check if there are any pending notifications.
| void set_notification_callback | ( | notification_callback_t | callback | ) |
Set an external notification callback.
When set, notifications will be delivered to this callback instead of being queued to pending_notifications_. This is useful for GUI clients that need to emit signals on notification receipt.
| callback | The callback to invoke on notification, or nullptr to revert to internal queuing |