ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
client Class Referencefinal

ORES protocol client. More...

#include <client.hpp>

Collaboration diagram for client:
Collaboration graph

Public Member Functions

 client (client_options config, std::shared_ptr< eventing::service::event_bus > event_bus=nullptr)
 Construct client with configuration.
 
 client (client_options config, boost::asio::any_io_executor executor, std::shared_ptr< eventing::service::event_bus > event_bus=nullptr)
 Construct client with configuration and executor.
 
 ~client ()
 Destructor.
 
boost::asio::awaitable< void > connect ()
 Connect to server and perform handshake (async version).
 
void connect_sync ()
 Connect to server and perform handshake (blocking version).
 
boost::asio::awaitable< void > connect_with_retry ()
 Connect to server with retry (async version).
 
void connect_with_retry_sync ()
 Connect to server with retry (blocking version).
 
void disconnect ()
 Disconnect from server.
 
bool is_connected () const
 Check if client is connected.
 
connection_state get_state () const
 Get the current connection state.
 
void set_disconnect_callback (disconnect_callback_t callback)
 Set callback to be invoked when disconnect is detected.
 
void set_reconnecting_callback (reconnecting_callback_t callback)
 Set callback to be invoked when reconnection starts.
 
void set_reconnected_callback (reconnected_callback_t callback)
 Set callback to be invoked when reconnection succeeds.
 
void set_notification_callback (notification_callback_t callback)
 Set callback to be invoked when a notification is received.
 
boost::asio::awaitable< std::expected< messaging::frame, messaging::error_code > > send_request (messaging::frame request_frame)
 Send a request frame and receive response frame (async version).
 
std::expected< messaging::frame, messaging::error_code > send_request_sync (messaging::frame request_frame)
 Send a request frame and receive response frame (blocking version).
 
template<typename RequestType , typename ResponseType , messaging::message_type RequestMsgType>
std::expected< ResponseType, messaging::error_code > process_request (RequestType request)
 Send typed request and receive typed response (blocking version).
 
template<typename RequestType , typename ResponseType , messaging::message_type RequestMsgType>
boost::asio::awaitable< std::expected< ResponseType, messaging::error_code > > process_request_async (RequestType request)
 Send typed request and receive typed response (async version).
 
template<typename RequestType >
requires messaging::has_message_traits<RequestType>
std::expected< typename messaging::message_traits< RequestType >::response_type, messaging::error_code > process_request (RequestType request)
 Send typed request using message_traits (blocking version).
 
template<typename RequestType >
requires messaging::has_message_traits<RequestType>
boost::asio::awaitable< std::expected< typename messaging::message_traits< RequestType >::response_type, messaging::error_code > > process_request_async (RequestType request)
 Send typed request using message_traits (async version).
 

Detailed Description

ORES protocol client.

Connects to server via SSL, performs handshake, and manages communication.

Constructor & Destructor Documentation

◆ client() [1/2]

client ( client_options  config,
std::shared_ptr< eventing::service::event_bus event_bus = nullptr 
)
explicit

Construct client with configuration.

Creates its own io_context for synchronous operations.

Parameters
configClient configuration options
event_busOptional event bus for publishing connection events

◆ client() [2/2]

client ( client_options  config,
boost::asio::any_io_executor  executor,
std::shared_ptr< eventing::service::event_bus event_bus = nullptr 
)
explicit

Construct client with configuration and executor.

Parameters
configClient configuration options
executorThe executor to use for async operations
event_busOptional event bus for publishing connection events

◆ ~client()

~client ( )

Destructor.

Ensures proper cleanup order - strand and pending requests must be destroyed before the io_context they reference.

Member Function Documentation

◆ connect()

boost::asio::awaitable< void > connect ( )

Connect to server and perform handshake (async version).

Single attempt connection without retries.

Exceptions
connection_errorif connection or handshake fails
Here is the caller graph for this function:

◆ connect_sync()

void connect_sync ( )

Connect to server and perform handshake (blocking version).

Single attempt connection without retries.

Exceptions
connection_errorif connection or handshake fails

◆ connect_with_retry()

boost::asio::awaitable< void > connect_with_retry ( )

Connect to server with retry (async version).

Attempts connection with exponential backoff according to retry_options.

Exceptions
connection_errorif all retry attempts fail
Here is the caller graph for this function:

◆ connect_with_retry_sync()

void connect_with_retry_sync ( )

Connect to server with retry (blocking version).

Attempts connection with exponential backoff according to retry_options.

Exceptions
connection_errorif all retry attempts fail

◆ is_connected()

bool is_connected ( ) const

Check if client is connected.

Returns true only when in the connected state, not during reconnection.

◆ set_disconnect_callback()

void set_disconnect_callback ( disconnect_callback_t  callback)

Set callback to be invoked when disconnect is detected.

The callback will be called from the heartbeat coroutine when a ping fails or times out. It should be thread-safe.

Parameters
callbackFunction to call on disconnect (may be empty to disable)

◆ set_reconnecting_callback()

void set_reconnecting_callback ( reconnecting_callback_t  callback)

Set callback to be invoked when reconnection starts.

The callback will be called when auto-reconnect begins after connection loss. It should be thread-safe.

Parameters
callbackFunction to call on reconnection start (may be empty to disable)

◆ set_reconnected_callback()

void set_reconnected_callback ( reconnected_callback_t  callback)

Set callback to be invoked when reconnection succeeds.

The callback will be called after auto-reconnect successfully restores the connection. It should be thread-safe.

Parameters
callbackFunction to call on reconnection success (may be empty to disable)

◆ set_notification_callback()

void set_notification_callback ( notification_callback_t  callback)

Set callback to be invoked when a notification is received.

The callback will be called when the server pushes a notification for an event type the client is subscribed to. It should be thread-safe.

Parameters
callbackFunction to call on notification (may be empty to disable)

◆ send_request()

boost::asio::awaitable< std::expected< messaging::frame, messaging::error_code > > send_request ( messaging::frame  request_frame)

Send a request frame and receive response frame (async version).

Generic method for sending any request and receiving response. Manages sequence numbers automatically.

Parameters
request_frameThe request frame to send
Returns
Expected containing response frame, or error_code
Here is the caller graph for this function:

◆ send_request_sync()

std::expected< messaging::frame, messaging::error_code > send_request_sync ( messaging::frame  request_frame)

Send a request frame and receive response frame (blocking version).

Generic method for sending any request and receiving response. Manages sequence numbers automatically.

Parameters
request_frameThe request frame to send
Returns
Expected containing response frame, or error_code
Here is the caller graph for this function:

◆ process_request() [1/2]

template<typename RequestType , typename ResponseType , messaging::message_type RequestMsgType>
std::expected< ResponseType, messaging::error_code > process_request ( RequestType  request)

Send typed request and receive typed response (blocking version).

Handles serialization, framing, decompression, and deserialization.

Template Parameters
RequestTypeRequest message type (must have serialize() method)
ResponseTypeResponse message type (must have static deserialize() method)
RequestMsgTypeThe message_type enum value for this request
Parameters
requestThe request to send
Returns
Expected containing deserialized response, or error_code
Here is the caller graph for this function:

◆ process_request_async() [1/2]

template<typename RequestType , typename ResponseType , messaging::message_type RequestMsgType>
boost::asio::awaitable< std::expected< ResponseType, messaging::error_code > > process_request_async ( RequestType  request)

Send typed request and receive typed response (async version).

Handles serialization, framing, decompression, and deserialization.

Template Parameters
RequestTypeRequest message type (must have serialize() method)
ResponseTypeResponse message type (must have static deserialize() method)
RequestMsgTypeThe message_type enum value for this request
Parameters
requestThe request to send
Returns
Awaitable containing deserialized response, or error_code
Here is the caller graph for this function:

◆ process_request() [2/2]

template<typename RequestType >
requires messaging::has_message_traits<RequestType>
std::expected< typename messaging::message_traits< RequestType >::response_type, messaging::error_code > process_request ( RequestType  request)

Send typed request using message_traits (blocking version).

Uses message_traits to automatically determine the response type and message_type enum value from the request type.

Template Parameters
RequestTypeRequest message type (must have message_traits)
Parameters
requestThe request to send
Returns
Expected containing deserialized response, or error_code

◆ process_request_async() [2/2]

template<typename RequestType >
requires messaging::has_message_traits<RequestType>
boost::asio::awaitable< std::expected< typename messaging::message_traits< RequestType >::response_type, messaging::error_code > > process_request_async ( RequestType  request)

Send typed request using message_traits (async version).

Uses message_traits to automatically determine the response type and message_type enum value from the request type.

Template Parameters
RequestTypeRequest message type (must have message_traits)
Parameters
requestThe request to send
Returns
Awaitable containing deserialized response, or error_code