MayaFlux 1.0.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 569 of file TCPBackend.cpp.

570{
571 if (!conn.reconnect_timer) {
572 conn.reconnect_timer = std::make_unique<asio::steady_timer>(m_context);
573 }
574
575 conn.reconnect_timer->expires_after(
576 std::chrono::milliseconds(m_config.reconnect_interval_ms));
577
578 conn.reconnect_timer->async_wait(
579 [this, ep_id = conn.info.id](const asio::error_code& ec) {
580 if (ec == asio::error::operation_aborted) {
581 return;
582 }
583
584 std::shared_lock lock(m_connections_mutex);
585 auto it = m_connections.find(ep_id);
586 if (it == m_connections.end()) {
587 return;
588 }
589
590 auto& c = *it->second;
591
592 c.socket = asio::ip::tcp::socket(m_context);
593
595 "TCP endpoint {} attempting reconnect to {}:{}",
596 ep_id, c.info.remote_address, c.info.remote_port);
597
598 start_connect(c);
599 });
600}
#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.