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

◆ start_receive_chain()

void MayaFlux::Core::TCPBackend::start_receive_chain ( ConnectionState &  conn)
private

Start the framed message receive chain on a connection.

Posts async_read for 4-byte header. Completion parses length, posts async_read for payload. Completion fires receive callback, then resubmits header read.

Definition at line 468 of file TCPBackend.cpp.

469{
470 asio::async_read(
471 conn.socket,
472 asio::buffer(conn.header_buf),
473 [this, ep_id = conn.info.id](const asio::error_code& ec, size_t bytes) {
474 std::shared_lock lock(m_connections_mutex);
475 auto it = m_connections.find(ep_id);
476 if (it == m_connections.end()) {
477 return;
478 }
479 on_header_received(*it->second, ec, bytes);
480 });
481}
void on_header_received(ConnectionState &conn, const asio::error_code &ec, size_t bytes)
Header read completion handler.

References MayaFlux::Core::TCPBackend::ConnectionState::header_buf, MayaFlux::Core::EndpointInfo::id, MayaFlux::Core::TCPBackend::ConnectionState::info, and MayaFlux::Core::TCPBackend::ConnectionState::socket.