93 class messaging_udp_server
94 :
public std::enable_shared_from_this<messaging_udp_server>
95 ,
public interfaces::i_udp_server
100 const asio::ip::udp::endpoint&)>;
146 [[nodiscard]] auto
server_id() const -> const std::
string&;
158 [[nodiscard]] auto
is_running() const ->
bool override;
199 std::vector<uint8_t>&& data,
260 const asio::ip::
udp::endpoint& endpoint) ->
void;
298 std::shared_ptr<internal::udp_socket>
socket_;
Thread-safe callback registration and invocation manager.
A UDP server that receives datagrams and routes them based on sender endpoint.
auto start_server(uint16_t port) -> VoidResult
Starts the server on the specified port.
auto stop_server() -> VoidResult
Stops the server and releases all resources.
auto do_start_impl(uint16_t port) -> VoidResult
UDP-specific implementation of server start.
auto is_running() const -> bool override
Checks if the server is currently running.
auto get_receive_callback() const -> receive_callback_t
Gets a copy of the receive callback.
utils::lifecycle_manager lifecycle_
~messaging_udp_server() noexcept override
Destructor. If the server is still running, stop_server() is invoked.
auto invoke_error_callback(std::error_code ec) -> void
Invokes the error callback with the given error code.
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 stop() -> VoidResult override
Stops the UDP server.
auto start(uint16_t port) -> VoidResult override
Starts the UDP server on the specified port.
auto send_to(const interfaces::i_udp_server::endpoint_info &endpoint, std::vector< uint8_t > &&data, interfaces::i_udp_server::send_callback_t handler=nullptr) -> VoidResult override
Sends a datagram to the specified endpoint.
auto get_error_callback() const -> error_callback_t
Gets a copy of the error callback.
messaging_udp_server(std::string_view server_id)
Constructs a messaging_udp_server with an identifier.
auto set_error_callback(error_callback_t callback) -> void override
Sets the callback for errors.
std::function< void(std::error_code)> error_callback_t
Callback type for errors.
auto wait_for_stop() -> void override
Blocks until stop_server() is called.
std::future< void > io_context_future_
std::unique_ptr< asio::io_context > io_context_
auto set_receive_callback(interfaces::i_udp_server::receive_callback_t callback) -> void override
Sets the callback for received datagrams (interface version).
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 do_stop_impl() -> VoidResult
UDP-specific implementation of server stop.
std::shared_ptr< internal::udp_socket > socket_
std::shared_ptr< integration::thread_pool_interface > thread_pool_
auto server_id() const -> const std::string &
Returns the server identifier.
std::function< void(std::error_code, std::size_t)> send_callback_t
Callback type for send completion.
Component lifecycle management (start, stop, restart).
udp_server_callback
Callback indices for messaging_udp_server.
Network-specific error and result type definitions.
Endpoint information for UDP datagrams.
Thread system integration interface for network_system.