MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ NetworkSource() [1/3]

MayaFlux::Vruta::NetworkSource::NetworkSource ( const Core::EndpointInfo info)
explicit

Open a network endpoint and begin receiving.

Parameters
infoEndpoint configuration.

Opens the endpoint via NetworkService and registers a receive callback that calls signal(). Logs a warning and remains inert if NetworkService is unavailable.

Definition at line 10 of file NetworkSource.cpp.

11{
13 .get_service<Registry::Service::NetworkService>();
14
15 if (!svc) {
17 "Cannot open NetworkSource: NetworkService not available");
18 return;
19 }
20
21 m_endpoint_id = svc->open_endpoint(info);
22
23 if (m_endpoint_id == 0) {
25 "NetworkSource: endpoint open failed");
26 return;
27 }
28
29 svc->set_endpoint_receive_callback(m_endpoint_id,
30 [this](uint64_t id, const uint8_t* data, size_t size, std::string_view addr) {
31 Core::NetworkMessage msg;
32 msg.endpoint_id = id;
33 msg.data.assign(data, data + size);
34 msg.sender_address = std::string(addr);
35 signal(msg);
36 });
37
39 "NetworkSource opened endpoint {}", m_endpoint_id);
40}
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
Range size
uint32_t id
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
void signal(const Core::NetworkMessage &message)
Signal that a message arrived (called from Asio IO thread)
@ Networking
Network operations (data transfer, protocol handling)
@ Vruta
Coroutines, schedulers, clocks, task management.

References MayaFlux::Core::NetworkMessage::data, MayaFlux::Core::NetworkMessage::endpoint_id, MayaFlux::Registry::BackendRegistry::get_service(), id, MayaFlux::Registry::BackendRegistry::instance(), m_endpoint_id, MF_DEBUG, MF_WARN, MayaFlux::Journal::Networking, MayaFlux::Core::NetworkMessage::sender_address, signal(), size, and MayaFlux::Journal::Vruta.

+ Here is the call graph for this function: