94 class messaging_udp_client
95 :
public std::enable_shared_from_this<messaging_udp_client>
96 ,
public interfaces::i_udp_client
101 const asio::ip::udp::endpoint&)>;
148 [[nodiscard]] auto
client_id() const -> const std::
string&;
160 [[nodiscard]] auto
is_running() const ->
bool override;
181 [[nodiscard]] auto
start(std::string_view host, uint16_t port) ->
VoidResult override;
199 [[nodiscard]] auto
send(
200 std::vector<uint8_t>&& data,
272 const asio::ip::
udp::endpoint& endpoint) ->
void;
310 std::shared_ptr<internal::udp_socket>
socket_;
Thread-safe callback registration and invocation manager.
A UDP client that sends datagrams to a target endpoint and can receive responses.
std::mutex endpoint_mutex_
auto invoke_receive_callback(const std::vector< uint8_t > &data, const asio::ip::udp::endpoint &endpoint) -> void
Invokes the receive callback with the given data and endpoint.
auto client_id() const -> const std::string &
Returns the client identifier.
auto send(std::vector< uint8_t > &&data, interfaces::i_udp_client::send_callback_t handler=nullptr) -> VoidResult override
Sends a datagram to the configured target endpoint.
auto wait_for_stop() -> void override
Blocks until stop_client() is called.
std::function< void(const std::vector< uint8_t > &, const asio::ip::udp::endpoint &)> receive_callback_t
Callback type for received datagrams with sender endpoint.
auto invoke_error_callback(std::error_code ec) -> void
Invokes the error callback with the given error code.
utils::lifecycle_manager lifecycle_
auto set_target(std::string_view host, uint16_t port) -> VoidResult override
Changes the target endpoint for future sends.
auto stop_client() -> VoidResult
Stops the client and releases all resources.
std::function< void(std::error_code)> error_callback_t
Callback type for errors.
auto do_stop_impl() -> VoidResult
UDP-specific implementation of client stop.
std::unique_ptr< asio::io_context > io_context_
asio::ip::udp::endpoint target_endpoint_
auto get_receive_callback() const -> receive_callback_t
Gets a copy of the receive callback.
messaging_udp_client(std::string_view client_id)
Constructs a messaging_udp_client with an identifier.
~messaging_udp_client() noexcept override
Destructor. Automatically calls stop_client() if the client is still running.
auto stop() -> VoidResult override
Stops the UDP client.
auto do_start_impl(std::string_view host, uint16_t port) -> VoidResult
UDP-specific implementation of client start.
auto start(std::string_view host, uint16_t port) -> VoidResult override
Starts the UDP client targeting the specified endpoint.
std::future< void > io_context_future_
auto is_running() const -> bool override
Checks if the client is currently running.
auto start_client(std::string_view host, uint16_t port) -> VoidResult
Starts the client by resolving target host and port.
auto set_error_callback(error_callback_t callback) -> void override
Sets the callback for errors.
auto get_error_callback() const -> error_callback_t
Gets a copy of the error callback.
std::shared_ptr< integration::thread_pool_interface > thread_pool_
auto set_receive_callback(interfaces::i_udp_client::receive_callback_t callback) -> void override
Sets the callback for received datagrams (interface version).
std::shared_ptr< internal::udp_socket > socket_
std::function< void(std::error_code, std::size_t)> send_callback_t
Callback type for send completion.
Component lifecycle management (start, stop, restart).
udp_client_callback
Callback indices for messaging_udp_client.
Network-specific error and result type definitions.
Thread system integration interface for network_system.