|
MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
|
Connectionless datagram transport over UDP via standalone Asio. More...
#include <UDPBackend.hpp>
Inheritance diagram for MayaFlux::Core::UDPBackend:
Collaboration diagram for MayaFlux::Core::UDPBackend:Classes | |
| struct | EndpointRecord |
| Per-endpoint state. More... | |
| struct | SocketState |
| Per-bound-port socket state. More... | |
Public Member Functions | |
| void | close_endpoint (uint64_t endpoint_id) override |
| Close an endpoint and release its resources. | |
| EndpointState | get_endpoint_state (uint64_t endpoint_id) const override |
| Query the current state of an endpoint. | |
| std::vector< EndpointInfo > | get_endpoints () const override |
| List all endpoints currently managed by this backend. | |
| std::string | get_name () const override |
| NetworkTransport | get_transport () const override |
| std::string | get_version () const override |
| bool | initialize () override |
| Initialise backend resources (sockets, SHM segments, etc.) | |
| bool | is_initialized () const override |
| bool | is_running () const override |
| uint64_t | open_endpoint (const EndpointInfo &info) override |
| Open a new endpoint. | |
| UDPBackend & | operator= (const UDPBackend &)=delete |
| UDPBackend & | operator= (UDPBackend &&)=delete |
| bool | send (uint64_t endpoint_id, const uint8_t *data, size_t size) override |
| Send data through an endpoint. | |
| bool | send_to (uint64_t endpoint_id, const uint8_t *data, size_t size, const std::string &address, uint16_t port) override |
| Send data to a specific address through an endpoint. | |
| void | set_receive_callback (NetworkReceiveCallback callback) override |
| Register the receive callback. | |
| void | set_state_callback (EndpointStateCallback callback) override |
| Register the endpoint state change callback. | |
| void | shutdown () override |
| Release all resources, close all endpoints. | |
| void | start () override |
| Start receive threads and accept connections. | |
| void | stop () override |
| Stop receive threads without releasing resources. | |
| UDPBackend (const UDPBackend &)=delete | |
| UDPBackend (const UDPBackendInfo &config, asio::io_context &context) | |
| Construct with config and a reference to the shared io_context. | |
| UDPBackend (UDPBackend &&)=delete | |
| ~UDPBackend () override | |
Public Member Functions inherited from MayaFlux::Core::INetworkBackend | |
| virtual | ~INetworkBackend ()=default |
Private Member Functions | |
| SocketState * | acquire_socket (uint16_t local_port) |
| Get or create a socket bound to local_port. | |
| void | on_receive (SocketState &state, const asio::error_code &ec, size_t bytes_received) |
| Completion handler for async_receive_from. | |
| void | release_socket (uint16_t local_port) |
| Decrement ref_count for a socket. | |
| uint64_t | resolve_endpoint_for_sender (uint16_t local_port, const asio::ip::udp::endpoint &sender) const |
| Resolve which endpoint id a received datagram belongs to. | |
| void | start_receive_loop (SocketState &state) |
| Post the first async_receive_from for a newly bound socket. | |
| void | transition_state (EndpointRecord &record, EndpointState new_state) |
Private Attributes | |
| UDPBackendInfo | m_config |
| asio::io_context & | m_context |
| std::unordered_map< uint64_t, EndpointRecord > | m_endpoints |
| std::shared_mutex | m_endpoints_mutex |
| std::atomic< bool > | m_initialized { false } |
| NetworkReceiveCallback | m_receive_callback |
| std::atomic< bool > | m_running { false } |
| std::unordered_map< uint16_t, std::unique_ptr< SocketState > > | m_sockets |
| std::shared_mutex | m_sockets_mutex |
| EndpointStateCallback | m_state_callback |
Connectionless datagram transport over UDP via standalone Asio.
Each endpoint maps to a (socket, optional default remote) pair. Endpoints that share a local port share the underlying socket.
All I/O is async on the io_context provided by NetworkSubsystem. No dedicated threads, no mutexes on the data path.
async_receive_from -> completion fires receive callback -> resubmit async_send_to -> fire-and-forget (UDP is unreliable anyway)
OSC, Art-Net, or any other datagram protocol is a serialisation concern above this layer. This backend knows nothing about message formats: bytes in, bytes out.
Definition at line 49 of file UDPBackend.hpp.