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

◆ schedule_reconnect()

void MayaFlux::Core::TCPBackend::schedule_reconnect ( ConnectionState conn)
private

Schedule a reconnect attempt after the configured interval.

Definition at line 565 of file TCPBackend.cpp.

566{
567 if (!conn.reconnect_timer) {
568 conn.reconnect_timer = std::make_unique<asio::steady_timer>(m_context);
569 }
570
571 conn.reconnect_timer->expires_after(
572 std::chrono::milliseconds(m_config.reconnect_interval_ms));
573
574 conn.reconnect_timer->async_wait(
575 [this, ep_id = conn.info.id](const asio::error_code& ec) {
576 if (ec == asio::error::operation_aborted) {
577 return;
578 }
579
580 std::shared_lock lock(m_connections_mutex);
581 auto it = m_connections.find(ep_id);
582 if (it == m_connections.end()) {
583 return;
584 }
585
586 auto& c = *it->second;
587
588 c.socket = asio::ip::tcp::socket(m_context);
589
591 "TCP endpoint {} attempting reconnect to {}:{}",
592 ep_id, c.info.remote_address, c.info.remote_port);
593
594 start_connect(c);
595 });
596}
#define MF_DEBUG(comp, ctx,...)
void start_connect(ConnectionState &conn)
Initiate async_connect for an outbound endpoint.
std::unordered_map< uint64_t, std::unique_ptr< ConnectionState > > m_connections
std::shared_mutex m_connections_mutex
asio::io_context & m_context
@ NetworkBackend
Network transport backend (UDP, TCP, SHM)
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::Core, MayaFlux::Core::EndpointInfo::id, MayaFlux::Core::TCPBackend::ConnectionState::info, MF_DEBUG, MayaFlux::Journal::NetworkBackend, and MayaFlux::Core::TCPBackend::ConnectionState::reconnect_timer.