24#include <asio/ssl.hpp>
71 class secure_messaging_client
72 :
public std::enable_shared_from_this<secure_messaging_client>
90 bool verify_cert =
true);
134 [[nodiscard]] auto
is_running() const noexcept ->
bool;
140 [[nodiscard]] auto
is_connected() const noexcept ->
bool;
146 [[nodiscard]] auto
client_id() const -> const std::
string&;
256 auto
on_receive(const std::vector<uint8_t>& data) ->
void;
262 auto
on_error(std::error_code ec) ->
void;
285 std::unique_ptr<asio::io_context>
287 std::unique_ptr<asio::executor_work_guard<asio::io_context::executor_type>>
290 std::shared_ptr<integration::thread_pool_interface>
295 std::unique_ptr<asio::ssl::context>
298 std::shared_ptr<internal::secure_tcp_socket>
Thread-safe callback registration and invocation manager.
A secure client for establishing TLS/SSL encrypted TCP connections to a server.
std::function< void()> connected_callback_t
Callback type for connection established.
utils::lifecycle_manager lifecycle_
~secure_messaging_client() noexcept
Destructor. Calls stop_client() if still connected.
auto on_receive(const std::vector< uint8_t > &data) -> void
Callback for when encrypted data arrives from the server.
auto send_packet(std::vector< uint8_t > &&data) -> VoidResult
Sends data to the connected server.
auto invoke_disconnected_callback() -> void
Invokes the disconnected callback.
auto client_id() const -> const std::string &
Returns the client identifier.
auto invoke_connected_callback() -> void
Invokes the connected callback.
auto set_receive_callback(receive_callback_t callback) -> void
Sets the callback for received data.
auto set_connected_callback(connected_callback_t callback) -> void
Sets the callback for connection established.
auto on_error(std::error_code ec) -> void
Callback for handling socket errors.
std::future< void > io_context_future_
auto stop_client() -> VoidResult
Stops the client and disconnects from the server.
auto do_stop_impl() -> VoidResult
Secure TCP-specific implementation of client stop.
std::shared_ptr< internal::secure_tcp_socket > socket_
std::function< void(std::error_code)> error_callback_t
Callback type for errors.
auto do_send_impl(std::vector< uint8_t > &&data) -> VoidResult
Secure TCP-specific implementation of data send.
auto invoke_receive_callback(const std::vector< uint8_t > &data) -> void
Invokes the receive callback.
auto wait_for_stop() -> void
Blocks until stop_client() is called.
secure_messaging_client(std::string_view client_id, bool verify_cert=true)
Constructs a secure messaging client.
std::atomic< bool > is_connected_
std::unique_ptr< asio::executor_work_guard< asio::io_context::executor_type > > work_guard_
auto is_running() const noexcept -> bool
Checks if the client is currently running.
auto set_error_callback(error_callback_t callback) -> void
Sets the callback for errors.
std::shared_ptr< integration::thread_pool_interface > thread_pool_
std::function< void(const std::vector< uint8_t > &)> receive_callback_t
Callback type for received data.
auto start_client(std::string_view host, unsigned short port) -> VoidResult
Starts the client and connects to the specified host and port.
auto set_connected(bool connected) -> void
Sets the connected state.
std::function< void()> disconnected_callback_t
Callback type for disconnection.
std::unique_ptr< asio::ssl::context > ssl_context_
auto is_connected() const noexcept -> bool
Checks if the client is connected to the server.
auto invoke_error_callback(std::error_code ec) -> void
Invokes the error callback.
auto do_start_impl(std::string_view host, unsigned short port) -> VoidResult
Secure TCP-specific implementation of client start.
auto set_disconnected_callback(disconnected_callback_t callback) -> void
Sets the callback for disconnection.
std::unique_ptr< asio::io_context > io_context_
Component lifecycle management (start, stop, restart).
tcp_client_callback
Callback indices for messaging_client and secure_messaging_client.
Network-specific error and result type definitions.
Thread system integration interface for network_system.