22 class PublishTrackHandler;
24 class SubscribeTrackHandler;
36 class Connection :
public std::enable_shared_from_this<Connection>
83 virtual void OnRecvDgram(
const std::shared_ptr<Connection>& connection) = 0;
93 virtual bool OnRecvStream(
const std::shared_ptr<Stream>& stream) = 0;
113 const MetricsTimeStamp sample_time,
134 const MetricsTimeStamp sample_time,
135 std::uint64_t stream_id,
151 std::uint64_t
GetID() const noexcept;
256 std::uint64_t
id{ 0 };
Async Callback API on the transport.
Definition: connection.h:62
virtual void OnStreamMetricsStampled(const std::shared_ptr< Connection > &connection, const MetricsTimeStamp sample_time, std::uint64_t stream_id, const QuicStreamMetrics &quic_stream_metrics, bool is_final)=0
callback notification on stream metrics sampled
virtual void OnConnectionStatus(const std::shared_ptr< Connection > &connection, Status status)=0
Event notification for connection status changes.
virtual void OnStreamClosed(const std::shared_ptr< Stream > &stream, StreamClosedFlag flag)=0
Callback notification that a stream has been closed by either FIN or RST.
virtual bool OnRecvStream(const std::shared_ptr< Stream > &stream)=0
callback notification that data has been received and should be processed
virtual void OnConnectionMetricsSampled(const std::shared_ptr< Connection > &connection, const MetricsTimeStamp sample_time, const QuicConnectionMetrics &quic_connection_metrics)=0
callback notification on connection metrics sampled
virtual ~Delegate()=default
Destroy the delegate.
virtual void OnRecvDgram(const std::shared_ptr< Connection > &connection)=0
callback notification that datagram data has been received and should be processed
Transport-independent state and callback dispatch for one connection.
Definition: connection.h:37
std::mutex mutex_
Definition: connection.h:263
Protocol protocol_
The protocol the connection uses. Default is Native Quic.
Definition: connection.h:259
virtual void OnRecvDgram()
callback notification that datagram data has been received and should be processed
std::shared_ptr< Stream > GetTxControlStream() const
std::optional< std::uint64_t > GetRxControlStreamId() const
void SetRxControlStreamId(std::uint64_t stream_id)
virtual QuicMetricsSample TakeMetricsSample()=0
Close the sample period, taking its metrics off the connection.
Status
Connection lifecycle state.
Definition: connection.h:48
@ kIdleTimeout
Closed because the idle timeout elapsed.
@ kShuttingDown
Transport shutdown is in progress.
@ kReady
Ready for application traffic.
@ kRemoteRequestClose
The peer requested closure.
@ kConnecting
Connection establishment is in progress.
@ kShutdown
Transport shutdown is complete.
@ kDisconnected
No longer connected.
std::weak_ptr< Delegate > delegate_
Non-owning event delegate guarded by the connection mutex.
Definition: connection.h:266
std::optional< std::uint64_t > first_unprocessed_request_id_
Definition: connection.h:275
virtual bool OnRecvStream(const std::shared_ptr< Stream > &stream)
callback notification that data has been received and should be processed
ConnectionMetrics metrics
Application-facing cumulative and current-period connection metrics.
Definition: connection.h:249
virtual void ReportMetricsSample(const MetricsTimeStamp &sample_time, const QuicMetricsSample &sample)=0
Report a taken sample to the delegate.
std::optional< std::uint64_t > GetFirstUnprocessedRequestId() const
Protocol
Network protocol negotiated for this connection.
Definition: connection.h:41
@ kNativeQuic
Native MoQ over QUIC.
@ kWebTransport
MoQ over a WebTransport session.
virtual ~Connection()=default
Destroy the connection.
std::uint64_t GetID() const noexcept
Return the transport-defined connection identifier.
void SetFirstUnprocessedRequestId(std::uint64_t request_id)
std::shared_ptr< Stream > tx_ctrl_stream_
Definition: connection.h:273
bool setup_sent_
Definition: connection.h:268
bool RecordSetupReceived()
bool IsSetupComplete() const
virtual void OnStatusChanged(Status status)
Event notification for connection status changes.
void SetDelegate(const std::shared_ptr< Delegate > &session)
Replace the non-owning callback delegate.
std::shared_ptr< Delegate > GetDelegate() const
Lock and promote the current weak delegate.
bool setup_received_
Definition: connection.h:269
Protocol GetProtocol() const noexcept
Return the network protocol used by this connection.
std::optional< std::uint64_t > rx_ctrl_stream_id_
Definition: connection.h:271
virtual void OnStreamClosed(const std::shared_ptr< Stream > &stream, StreamClosedFlag flag)
Callback notification that a stream has been closed by either FIN or RST.
Connection(std::uint64_t id, Protocol protocol=Protocol::kNativeQuic)
Construct connection state in Status::kConnecting.
std::atomic< Status > status_
Current lifecycle state.
Definition: connection.h:261
void SetTxControlStream(std::shared_ptr< Stream > stream)
void SetStatus(Status new_status)
Change connection status and notify the delegate.
Status GetStatus() const noexcept
Return the current connection status.
Definition: connection.h:167
Definition: attributes.h:13
StreamClosedFlag
Peer or transport event that closed a stream direction.
Definition: connection.h:29
@ kStopSending
The peer requested that the local send direction stop.
@ kFin
The send direction ended normally with FIN.
@ kReset
The send direction ended abruptly with RESET_STREAM.
Application-facing metrics for one connection sample period.
Definition: metrics.h:326
QUIC connection counters and period aggregates.
Definition: metrics.h:85
One sample period's metrics for a connection and the streams on it.
Definition: metrics.h:223
Metrics produced by a single QUIC stream over one sample period.
Definition: metrics.h:136
Portable wrappers for Clang thread-safety analysis attributes.
#define QUICR_GUARDED_BY(...)
No-op guarded-field annotation when thread-safety annotations are disabled.
Definition: thread_safety.h:64