|
LibQuicR
|
Transport-independent state and callback dispatch for one connection. More...
#include <connection.h>
Classes | |
| class | Delegate |
| Async Callback API on the transport. More... | |
Public Types | |
| enum class | Protocol : std::uint8_t { kNativeQuic , kWebTransport } |
| Network protocol negotiated for this connection. More... | |
| enum class | Status : std::uint8_t { kReady = 0 , kConnecting , kRemoteRequestClose , kDisconnected , kIdleTimeout , kShutdown , kShuttingDown } |
| Connection lifecycle state. More... | |
Public Member Functions | |
| Connection (std::uint64_t id, Protocol protocol=Protocol::kNativeQuic) | |
Construct connection state in Status::kConnecting. More... | |
| virtual | ~Connection ()=default |
| Destroy the connection. More... | |
| std::uint64_t | GetID () const noexcept |
| Return the transport-defined connection identifier. More... | |
| Protocol | GetProtocol () const noexcept |
| Return the network protocol used by this connection. More... | |
| void | SetStatus (Status new_status) |
| Change connection status and notify the delegate. More... | |
| Status | GetStatus () const noexcept |
| Return the current connection status. More... | |
| void | SetDelegate (const std::shared_ptr< Delegate > &session) |
| Replace the non-owning callback delegate. More... | |
| virtual QuicMetricsSample | TakeMetricsSample ()=0 |
| Close the sample period, taking its metrics off the connection. More... | |
| virtual void | ReportMetricsSample (const MetricsTimeStamp &sample_time, const QuicMetricsSample &sample)=0 |
| Report a taken sample to the delegate. More... | |
| virtual void | OnStatusChanged (Status status) |
| Event notification for connection status changes. More... | |
| virtual void | OnRecvDgram () |
| callback notification that datagram data has been received and should be processed More... | |
| virtual bool | OnRecvStream (const std::shared_ptr< Stream > &stream) |
| callback notification that data has been received and should be processed More... | |
| virtual void | OnStreamClosed (const std::shared_ptr< Stream > &stream, StreamClosedFlag flag) |
| Callback notification that a stream has been closed by either FIN or RST. More... | |
| bool | RecordSetupSent () |
| bool | RecordSetupReceived () |
| bool | IsSetupComplete () const |
| void | SetRxControlStreamId (std::uint64_t stream_id) |
| std::optional< std::uint64_t > | GetRxControlStreamId () const |
| void | SetTxControlStream (std::shared_ptr< Stream > stream) |
| std::shared_ptr< Stream > | GetTxControlStream () const |
| void | SetFirstUnprocessedRequestId (std::uint64_t request_id) |
| std::optional< std::uint64_t > | GetFirstUnprocessedRequestId () const |
Public Attributes | |
| ConnectionMetrics | metrics {} |
| Application-facing cumulative and current-period connection metrics. More... | |
Protected Member Functions | |
| std::shared_ptr< Delegate > | GetDelegate () const |
| Lock and promote the current weak delegate. More... | |
Protected Attributes | |
| std::uint64_t | id { 0 } |
| Transport-defined connection identifier. More... | |
| Protocol | protocol_ { Protocol::kNativeQuic } |
| The protocol the connection uses. Default is Native Quic. More... | |
| std::atomic< Status > | status_ |
| Current lifecycle state. More... | |
| std::mutex | mutex_ |
| std::weak_ptr< Delegate > | delegate_ |
| Non-owning event delegate guarded by the connection mutex. More... | |
| bool | setup_sent_ { false } |
| bool | setup_received_ { false } |
| std::optional< std::uint64_t > | rx_ctrl_stream_id_ |
| std::shared_ptr< Stream > | tx_ctrl_stream_ |
| std::optional< std::uint64_t > | first_unprocessed_request_id_ |
Transport-independent state and callback dispatch for one connection.
|
strong |
|
strong |
Connection lifecycle state.
| Enumerator | |
|---|---|
| kReady | Ready for application traffic. |
| kConnecting | Connection establishment is in progress. |
| kRemoteRequestClose | The peer requested closure. |
| kDisconnected | No longer connected. |
| kIdleTimeout | Closed because the idle timeout elapsed. |
| kShutdown | Transport shutdown is complete. |
| kShuttingDown | Transport shutdown is in progress. |
| quicr::Connection::Connection | ( | std::uint64_t | id, |
| Protocol | protocol = Protocol::kNativeQuic |
||
| ) |
Construct connection state in Status::kConnecting.
| id | Transport-defined connection identifier. |
| protocol | Network protocol used by the connection. |
|
virtualdefault |
Destroy the connection.
|
protected |
Lock and promote the current weak delegate.
| std::optional<std::uint64_t> quicr::Connection::GetFirstUnprocessedRequestId | ( | ) | const |
|
noexcept |
Return the transport-defined connection identifier.
|
noexcept |
Return the network protocol used by this connection.
| std::optional<std::uint64_t> quicr::Connection::GetRxControlStreamId | ( | ) | const |
|
inlinenoexcept |
Return the current connection status.
| std::shared_ptr<Stream> quicr::Connection::GetTxControlStream | ( | ) | const |
| bool quicr::Connection::IsSetupComplete | ( | ) | const |
|
virtual |
callback notification that datagram data has been received and should be processed
|
virtual |
callback notification that data has been received and should be processed
| stream | Stream the data arrived on, carrying its receive queue and the handler consuming it. |
|
virtual |
Event notification for connection status changes.
Called when the connection changes state/status
| status | Transport status value. |
|
virtual |
Callback notification that a stream has been closed by either FIN or RST.
| stream | Stream that closed, carrying the handler it belonged to |
| flag | Flag value for how the stream was closed. Values are FIN or RST |
| bool quicr::Connection::RecordSetupReceived | ( | ) |
| bool quicr::Connection::RecordSetupSent | ( | ) |
|
pure virtual |
Report a taken sample to the delegate.
Separate from taking it so the reporting can be handed to the delegate's thread without leaving the counters exposed to it.
| sample_time | Wall-clock time associated with the sample. |
| sample | Metrics previously returned by TakeMetricsSample. |
| void quicr::Connection::SetDelegate | ( | const std::shared_ptr< Delegate > & | session | ) |
Replace the non-owning callback delegate.
| session | Delegate to observe events, or null to detach it. |
The connection stores a weak reference. Attaching after connection establishment immediately replays the current non-connecting status.
| void quicr::Connection::SetFirstUnprocessedRequestId | ( | std::uint64_t | request_id | ) |
| void quicr::Connection::SetRxControlStreamId | ( | std::uint64_t | stream_id | ) |
| void quicr::Connection::SetStatus | ( | Status | new_status | ) |
Change connection status and notify the delegate.
| new_status | New lifecycle state. |
| void quicr::Connection::SetTxControlStream | ( | std::shared_ptr< Stream > | stream | ) |
|
pure virtual |
Close the sample period, taking its metrics off the connection.
PicoQuicTransport::EmitMetrics for the transport's.
|
protected |
Non-owning event delegate guarded by the connection mutex.
|
protected |
|
protected |
Transport-defined connection identifier.
| ConnectionMetrics quicr::Connection::metrics {} |
Application-facing cumulative and current-period connection metrics.
|
mutableprotected |
|
protected |
The protocol the connection uses. Default is Native Quic.
|
protected |
|
protected |
|
protected |
|
protected |
Current lifecycle state.
|
protected |