|
MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
|
General-purpose network transport subsystem. More...
#include <NetworkSubsystem.hpp>
Inheritance diagram for MayaFlux::Core::NetworkSubsystem:
Collaboration diagram for MayaFlux::Core::NetworkSubsystem:Public Member Functions | |
| bool | add_backend (std::unique_ptr< INetworkBackend > backend) |
| Add a network backend. | |
| void | close_endpoint (uint64_t endpoint_id) |
| Close an endpoint. | |
| std::vector< EndpointInfo > | get_all_endpoints () const |
| List all open endpoints across all backends. | |
| INetworkBackend * | get_backend (NetworkTransport transport) const |
| Get a backend by transport type. | |
| std::vector< INetworkBackend * > | get_backends () const |
| Get all active backends. | |
| EndpointState | get_endpoint_state (uint64_t endpoint_id) const |
| Query endpoint state. | |
| SubsystemProcessingHandle * | get_processing_context_handle () override |
| Get the processing context handle for this subsystem. | |
| SubsystemTokens | get_tokens () const override |
| Get the processing token configuration this subsystem manages. | |
| SubsystemType | get_type () const override |
| Get the type of this subsystem. | |
| void | initialize (SubsystemProcessingHandle &handle) override |
| Initialize with a handle provided by SubsystemManager. | |
| bool | is_ready () const override |
| Check if subsystem is ready for operation. | |
| bool | is_running () const override |
| Check if subsystem is currently processing. | |
| NetworkSubsystem (const GlobalNetworkConfig &config) | |
| NetworkSubsystem (const NetworkSubsystem &)=delete | |
| NetworkSubsystem (NetworkSubsystem &&)=delete | |
| uint64_t | open_endpoint (const EndpointInfo &info) |
| Open an endpoint on the backend matching info.transport. | |
| NetworkSubsystem & | operator= (const NetworkSubsystem &)=delete |
| NetworkSubsystem & | operator= (NetworkSubsystem &&)=delete |
| void | pause () override |
| Pause the subsystem's processing/event loops. | |
| void | register_callbacks () override |
| Register callback hooks for this domain. | |
| void | resume () override |
| Resume the subsystem's processing/event loops. | |
| bool | send (uint64_t endpoint_id, const uint8_t *data, size_t size) |
| 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) |
| Send data to a specific address. | |
| void | set_endpoint_receive_callback (uint64_t endpoint_id, NetworkReceiveCallback callback) |
| Register a per-endpoint receive callback. | |
| void | shutdown () override |
| Shutdown and cleanup subsystem resources. | |
| void | start () override |
| Start the subsystem's processing/event loops. | |
| void | stop () override |
| Stop the subsystem's processing/event loops. | |
| ~NetworkSubsystem () override | |
Public Member Functions inherited from MayaFlux::Core::ISubsystem | |
| virtual | ~ISubsystem ()=default |
Private Member Functions | |
| void | initialize_shm_backend () |
| void | initialize_tcp_backend () |
| void | initialize_udp_backend () |
| void | on_backend_receive (uint64_t endpoint_id, const uint8_t *data, size_t size, std::string_view sender_addr) |
| Wired as the receive callback on each backend. | |
| void | on_backend_state_change (const EndpointInfo &info, EndpointState previous, EndpointState current) |
| Wired as the state callback on each backend. | |
| void | register_backend_service () |
| INetworkBackend * | resolve_backend (uint64_t endpoint_id) const |
| Resolve endpoint_id to its owning backend. | |
Private Attributes | |
| std::unordered_map< NetworkTransport, std::unique_ptr< INetworkBackend > > | m_backends |
| std::shared_mutex | m_backends_mutex |
| std::shared_mutex | m_callbacks_mutex |
| Per-endpoint receive callbacks set by consumers via set_endpoint_receive_callback(). | |
| GlobalNetworkConfig | m_config |
| std::unordered_map< uint64_t, NetworkReceiveCallback > | m_endpoint_callbacks |
| std::unordered_map< uint64_t, NetworkTransport > | m_endpoint_routing |
| SubsystemProcessingHandle * | m_handle { nullptr } |
| std::unique_ptr< asio::io_context > | m_io_context |
| std::atomic< bool > | m_io_stop_requested { false } |
| std::thread | m_io_thread |
| std::shared_ptr< Registry::Service::NetworkService > | m_network_service |
| std::atomic< uint64_t > | m_next_endpoint_id { 1 } |
| Global endpoint id counter shared across all backends. | |
| std::atomic< bool > | m_ready { false } |
| std::shared_mutex | m_routing_mutex |
| Maps endpoint_id -> transport for routing send/close/query to the correct backend without scanning all backends. | |
| std::atomic< bool > | m_running { false } |
| SubsystemTokens | m_tokens |
| std::unique_ptr< asio::executor_work_guard< asio::io_context::executor_type > > | m_work_guard |
General-purpose network transport subsystem.
Owns multiple INetworkBackend instances (UDP, TCP, SharedMemory) and registers a NetworkService into BackendRegistry for decoupled access by any engine component.
Structural parallel to InputSubsystem:
Key difference: InputSubsystem is receive-only (InputCallback delivers events to InputManager). NetworkSubsystem is bidirectional. It provides send and receive through NetworkService, and manages persistent endpoints rather than device handles.
Relationship to InputSubsystem's OSC/Serial stubs: InputSubsystem::initialize_osc_backend() will create an OSCBackend (IInputBackend) that internally obtains a UDP endpoint through NetworkService. The OSCBackend handles OSC address parsing and produces InputValue events. The actual socket is managed here. Same pattern for Serial if it ever rides over TCP or SHM.
Endpoint IDs are globally unique across all backends. The subsystem maintains a transport-to-backend routing map so callers never need to know which backend handles their endpoint.
Tokens: Buffer = NETWORK_BACKEND (new ProcessingToken) Node = EVENT_RATE (shared with InputSubsystem, async arrival) Task = EVENT_DRIVEN (shared with InputSubsystem)
Definition at line 60 of file NetworkSubsystem.hpp.