24#include <openssl/ssl.h>
82 class secure_messaging_udp_client
83 :
public std::enable_shared_from_this<secure_messaging_udp_client>
97 const asio::ip::udp::endpoint&)>;
148 [[nodiscard]] auto
is_running() const noexcept ->
bool;
154 [[nodiscard]] auto
is_connected() const noexcept ->
bool;
160 [[nodiscard]] auto
client_id() const -> const std::
string&;
180 std::vector<uint8_t>&& data,
181 std::function<
void(std::error_code, std::
size_t)> handler) ->
VoidResult;
313 std::shared_ptr<internal::dtls_socket>
socket_;
Thread-safe callback registration and invocation manager.
A secure UDP client using DTLS (Datagram TLS) for encrypted communication.
auto invoke_disconnected_callback() -> void
Invokes the disconnected callback.
auto set_error_callback(error_callback_t callback) -> void
Sets the callback for errors.
std::atomic< bool > is_connected_
auto set_udp_receive_callback(udp_receive_callback_t callback) -> void
Sets a UDP-specific callback to handle received decrypted datagrams.
auto send_packet_with_handler(std::vector< uint8_t > &&data, std::function< void(std::error_code, std::size_t)> handler) -> VoidResult
Sends an encrypted datagram with a completion handler.
auto set_disconnected_callback(disconnected_callback_t callback) -> void
Sets the callback for disconnection.
auto do_start_impl(std::string_view host, unsigned short port) -> VoidResult
DTLS-specific implementation of client start.
auto init_ssl_context() -> VoidResult
Initializes the SSL context for DTLS.
auto do_send_impl(std::vector< uint8_t > &&data) -> VoidResult
DTLS-specific implementation of data send.
auto start_client(std::string_view host, unsigned short port) -> VoidResult
Starts the client and connects to the specified host and port.
std::function< void(const std::vector< uint8_t > &)> receive_callback_t
Callback type for received data.
~secure_messaging_udp_client() noexcept
Destructor. Automatically calls stop_client() if still running.
auto invoke_connected_callback() -> void
Invokes the connected callback.
auto do_stop_impl() -> VoidResult
DTLS-specific implementation of client stop.
asio::ip::udp::endpoint target_endpoint_
std::function< void()> connected_callback_t
Callback type for connection established.
std::mutex udp_callback_mutex_
UDP-specific receive callback (includes sender endpoint)
secure_messaging_udp_client(std::string_view client_id, bool verify_cert=true)
Constructs a secure_messaging_udp_client with an identifier.
auto stop_client() -> VoidResult
Stops the client and disconnects.
std::shared_ptr< internal::dtls_socket > socket_
auto invoke_error_callback(std::error_code ec) -> void
Invokes the error callback.
std::mutex endpoint_mutex_
auto invoke_receive_callback(const std::vector< uint8_t > &data) -> void
Invokes the receive callback.
std::function< void()> disconnected_callback_t
Callback type for disconnection.
auto client_id() const -> const std::string &
Returns the client identifier.
utils::lifecycle_manager lifecycle_
auto is_connected() const noexcept -> bool
Checks if the client is connected to the server.
auto send_packet(std::vector< uint8_t > &&data) -> VoidResult
Sends an encrypted datagram to the server.
std::unique_ptr< asio::io_context > io_context_
auto is_running() const noexcept -> bool
Checks if the client is currently running.
std::shared_ptr< integration::thread_pool_interface > thread_pool_
auto set_receive_callback(receive_callback_t callback) -> void
Sets the callback for received data.
auto set_connected(bool connected) -> void
Sets the connected state.
udp_receive_callback_t udp_receive_callback_
auto wait_for_stop() -> void
Blocks until stop_client() is called.
std::function< void(const std::vector< uint8_t > &, const asio::ip::udp::endpoint &)> udp_receive_callback_t
UDP-specific receive callback type with sender endpoint.
std::future< void > io_context_future_
std::function< void(std::error_code)> error_callback_t
Callback type for errors.
auto do_handshake() -> VoidResult
Performs the DTLS handshake.
auto set_connected_callback(connected_callback_t callback) -> void
Sets the callback for connection established.
struct ssl_ctx_st SSL_CTX
Component lifecycle management (start, stop, restart).
secure_udp_client_callback
Callback indices for secure_messaging_udp_client.
Network-specific error and result type definitions.
Thread system integration interface for network_system.