|
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 | disconnected () |
| void | reconnecting () |
| void | reconnected () |
| void | connectionError (const QString &message) |
| void | notificationReceived (const QString &eventType, const QDateTime ×tamp) |
| Emitted when a notification is received from the server. | |
Public Member Functions | |
| ClientManager (std::shared_ptr< eventing::service::event_bus > event_bus, QObject *parent=nullptr) | |
| std::pair< bool, QString > | connectAndLogin (const std::string &host, std::uint16_t port, const std::string &username, const std::string &password) |
| Connect to the server and perform login. | |
| 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. | |
| std::expected< comms::messaging::frame, comms::messaging::error_code > | sendRequest (comms::messaging::frame request) |
| Send a request if connected. | |
| 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. | |
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.
| std::pair< bool, QString > connectAndLogin | ( | const std::string & | host, |
| std::uint16_t | port, | ||
| const std::string & | username, | ||
| const std::string & | password | ||
| ) |
Connect to the server and perform login.
| host | Server hostname |
| port | Server port |
| username | Login username |
| password | Login 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.
| std::expected< comms::messaging::frame, comms::messaging::error_code > sendRequest | ( | comms::messaging::frame | request | ) |
Send a request if connected.
| request | The request frame to send |
| 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.risk.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) |
|
signal |
Emitted when a notification is received from the server.
| eventType | The event type name (e.g., "ores.risk.currency_changed_event") |
| timestamp | When the event occurred |
