405{
407
408 auto service = std::make_shared<Registry::Service::NetworkService>();
409
410 service->open_endpoint = [this](const EndpointInfo& info) {
412 };
413
414 service->close_endpoint = [this](uint64_t id) {
416 };
417
418 service->send = [this](uint64_t id, const uint8_t* data, size_t size) {
419 return send(
id, data, size);
420 };
421
422 service->send_to = [this](uint64_t id, const uint8_t* data, size_t size,
423 const std::string& addr, uint16_t port) {
424 return send_to(
id, data, size, addr, port);
425 };
426
427 service->get_endpoint_state = [this](uint64_t id) {
429 };
430
433 };
434
435 service->get_all_endpoints = [this]() {
437 };
438
440
441 registry.register_service<Registry::Service::NetworkService>(
442 [service]() -> void* {
443 return service.get();
444 });
445}
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.