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

◆ resolve_endpoint_for_sender()

uint64_t MayaFlux::Core::UDPBackend::resolve_endpoint_for_sender ( uint16_t  local_port,
const asio::ip::udp::endpoint &  sender 
) const
private

Resolve which endpoint id a received datagram belongs to.

For a given socket (local port), checks if any endpoint has a default_remote matching the sender. If none match, falls back to the first RECEIVE or BIDIRECTIONAL endpoint on that port.

Definition at line 391 of file UDPBackend.cpp.

393{
394 std::shared_lock lock(m_endpoints_mutex);
395
396 uint64_t fallback_id = 0;
397
398 for (const auto& [id, record] : m_endpoints) {
399 if (record.socket_state->local_port != local_port) {
400 continue;
401 }
402
403 if (record.has_default_remote
404 && record.default_remote.address() == sender.address()
405 && record.default_remote.port() == sender.port()) {
406 return id;
407 }
408
409 if (fallback_id == 0
410 && (record.info.role == EndpointRole::RECEIVE
411 || record.info.role == EndpointRole::BIDIRECTIONAL)) {
412 fallback_id = id;
413 }
414 }
415
416 return fallback_id;
417}
uint32_t id
std::unordered_map< uint64_t, EndpointRecord > m_endpoints
std::shared_mutex m_endpoints_mutex

References MayaFlux::Core::BIDIRECTIONAL, id, m_endpoints, m_endpoints_mutex, and MayaFlux::Core::RECEIVE.