MayaFlux 0.4.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 464 of file TCPBackend.cpp.

465{
466 asio::async_read(
467 conn.socket,
468 asio::buffer(conn.header_buf),
469 [this, ep_id = conn.info.id](const asio::error_code& ec, size_t bytes) {
470 std::shared_lock lock(m_connections_mutex);
471 auto it = m_connections.find(ep_id);
472 if (it == m_connections.end()) {
473 return;
474 }
475 on_header_received(*it->second, ec, bytes);
476 });
477}
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.