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

◆ register_backend_service()

void MayaFlux::Core::NetworkSubsystem::register_backend_service ( )
private

Definition at line 398 of file NetworkSubsystem.cpp.

399{
400 auto& registry = Registry::BackendRegistry::instance();
401
402 auto service = std::make_shared<Registry::Service::NetworkService>();
403
404 service->open_endpoint = [this](const EndpointInfo& info) {
405 return open_endpoint(info);
406 };
407
408 service->close_endpoint = [this](uint64_t id) {
409 close_endpoint(id);
410 };
411
412 service->send = [this](uint64_t id, const uint8_t* data, size_t size) {
413 return send(id, data, size);
414 };
415
416 service->send_to = [this](uint64_t id, const uint8_t* data, size_t size,
417 const std::string& addr, uint16_t port) {
418 return send_to(id, data, size, addr, port);
419 };
420
421 service->get_endpoint_state = [this](uint64_t id) {
422 return get_endpoint_state(id);
423 };
424
425 service->set_endpoint_receive_callback = [this](uint64_t id, NetworkReceiveCallback cb) {
426 set_endpoint_receive_callback(id, std::move(cb));
427 };
428
429 service->get_all_endpoints = [this]() {
430 return get_all_endpoints();
431 };
432
433 m_network_service = service;
434
435 registry.register_service<Registry::Service::NetworkService>(
436 [service]() -> void* {
437 return service.get();
438 });
439}
Range size
uint32_t id
uint64_t open_endpoint(const EndpointInfo &info)
Open an endpoint on the backend matching info.transport.
std::vector< EndpointInfo > get_all_endpoints() const
List all open endpoints across all backends.
void set_endpoint_receive_callback(uint64_t endpoint_id, NetworkReceiveCallback callback)
Register a per-endpoint receive callback.
void close_endpoint(uint64_t endpoint_id)
Close an endpoint.
bool send(uint64_t endpoint_id, const uint8_t *data, size_t size)
Send data through an endpoint.
EndpointState get_endpoint_state(uint64_t endpoint_id) const
Query endpoint state.
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.
std::shared_ptr< Registry::Service::NetworkService > m_network_service
static BackendRegistry & instance()
Get the global registry instance.
std::function< void(uint64_t endpoint_id, const uint8_t *data, size_t size, std::string_view sender_addr)> NetworkReceiveCallback
Callback signature for inbound data on an endpoint.

References id, MayaFlux::Registry::BackendRegistry::instance(), and size.

Referenced by initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: