LibQuicR
quicr::TrackHandler Class Referenceabstract

Common request state for track-related handlers. More...

#include <track_handler.h>

Inheritance diagram for quicr::TrackHandler:
quicr::PublishNamespaceHandler quicr::PublishTrackHandler quicr::SubscribeNamespaceHandler quicr::SubscribeTrackHandler quicr::TrackStatusHandler quicr::PublishFetchHandler quicr::FetchTrackHandler quicr::ForwardingSubscribeTrackHandler quicr::JoiningFetchHandler

Classes

struct  Binding
 

Public Member Functions

virtual ~TrackHandler ()=default
 Releases this handler; shared stream/session handles are released automatically. More...
 
 TrackHandler ()=delete
 A track identity is mandatory. More...
 
template<typename T >
requires std::is_base_of_v< TrackHandler, T > std::shared_ptr< T > Get ()
 Get the derived type of the track handler. More...
 
void SetRequestId (std::optional< uint64_t > request_id)
 Sets or clears the connection-scoped request ID. More...
 
std::optional< uint64_t > GetRequestId () const noexcept
 Get the request ID. More...
 
std::optional< uint64_t > GetRequestStreamId () const
 Get the stream ID of the request control stream. More...
 
FullTrackName GetFullTrackName () const noexcept
 Get the full track name. More...
 
uint64_t GetConnectionId () const noexcept
 Gets the transport connection identifier assigned by the session. More...
 
std::shared_ptr< Connection > GetConnection () const
 
Binding GetBinding () const
 
virtual Reply< messages::Parameters, ErrorCode > RequestUpdateReceived (const messages::Parameters &params)=0
 Received an update for this handler's request. More...
 
virtual void RequestError (ErrorCode error_code, std::string reason)
 Handles a REQUEST_ERROR for this handler. More...
 

Protected Member Functions

 TrackHandler (const FullTrackName &full_track_name)
 Constructs a handler for one full track name. More...
 
virtual void RequestOkReceived (const messages::Parameters &params)=0
 Handles REQUEST_OK for this handler's request. More...
 
void SetTransport (std::shared_ptr< Session > transport)
 Sets the session used for control and data operations. More...
 
const std::weak_ptr< Session > & GetSession () const noexcept
 Gets the non-owning session handle. More...
 

Protected Attributes

FullTrackName full_track_name_
 Full track identity retained for the handler's lifetime. More...
 
std::mutex binding_operation_mutex_
 

Detailed Description

Common request state for track-related handlers.

Handlers are intended to be managed by std::shared_ptr; Get() and session registration rely on shared ownership. Request stream access is synchronized, while most other fields are initialized or mutated by the session and are not generally thread-safe.

Constructor & Destructor Documentation

◆ ~TrackHandler()

virtual quicr::TrackHandler::~TrackHandler ( )
virtualdefault

Releases this handler; shared stream/session handles are released automatically.

◆ TrackHandler() [1/2]

quicr::TrackHandler::TrackHandler ( )
delete

A track identity is mandatory.

◆ TrackHandler() [2/2]

quicr::TrackHandler::TrackHandler ( const FullTrackName &  full_track_name)
inlineprotected

Constructs a handler for one full track name.

Parameters
full_track_nameTrack identity copied into the handler.

Member Function Documentation

◆ Get()

template<typename T >
requires std::is_base_of_v<TrackHandler, T> std::shared_ptr<T> quicr::TrackHandler::Get ( )
inline

Get the derived type of the track handler.

Template Parameters
TDerived type of the track handler.
Returns
Shared ownership cast to T, or null when the dynamic type is incompatible.
Exceptions
std::bad_weak_ptrif this object is not currently owned by a shared_ptr.

◆ GetBinding()

Binding quicr::TrackHandler::GetBinding ( ) const
inline

◆ GetConnection()

std::shared_ptr<Connection> quicr::TrackHandler::GetConnection ( ) const

◆ GetConnectionId()

uint64_t quicr::TrackHandler::GetConnectionId ( ) const
inlinenoexcept

Gets the transport connection identifier assigned by the session.

Returns
Connection ID, or the initial value zero before assignment.

◆ GetFullTrackName()

FullTrackName quicr::TrackHandler::GetFullTrackName ( ) const
inlinenoexcept

Get the full track name.

Returns
A copy of the full track name.

◆ GetRequestId()

std::optional<uint64_t> quicr::TrackHandler::GetRequestId ( ) const
inlinenoexcept

Get the request ID.

Returns
Current connection-scoped request ID, or std::nullopt when none is assigned.

◆ GetRequestStreamId()

std::optional<uint64_t> quicr::TrackHandler::GetRequestStreamId ( ) const

Get the stream ID of the request control stream.

Returns
Request stream's ID, or std::nullopt if no stream is attached.
Note
Thread-safe with request-stream installation/removal.

◆ GetSession()

const std::weak_ptr<Session>& quicr::TrackHandler::GetSession ( ) const
protectednoexcept

Gets the non-owning session handle.

Returns
Borrowed reference to the stored weak pointer, valid for this handler's lifetime. Callers must lock it before use.

◆ RequestError()

virtual void quicr::TrackHandler::RequestError ( ErrorCode  error_code,
std::string  reason 
)
virtual

Handles a REQUEST_ERROR for this handler.

Parameters
error_codePeer-provided request error code.
reasonPeer-provided reason, passed by value for optional retention.
Note
The base implementation intentionally does nothing.

Reimplemented in quicr::TrackStatusHandler, quicr::SubscribeNamespaceHandler, and quicr::PublishNamespaceHandler.

◆ RequestOkReceived()

virtual void quicr::TrackHandler::RequestOkReceived ( const messages::Parameters &  params)
protectedpure virtual

Handles REQUEST_OK for this handler's request.

Parameters
paramsBorrowed response parameters, valid only for this callback.
Exceptions
messages::ProtocolViolationExceptionwhen parameters violate the request contract.

Implemented in quicr::TrackStatusHandler, quicr::SubscribeTrackHandler, quicr::SubscribeNamespaceHandler, quicr::PublishTrackHandler, and quicr::PublishNamespaceHandler.

◆ RequestUpdateReceived()

virtual Reply<messages::Parameters, ErrorCode> quicr::TrackHandler::RequestUpdateReceived ( const messages::Parameters &  params)
pure virtual

Received an update for this handler's request.

The session acknowledges the update with the returned reply: success sends REQUEST_UPDATE_OK with its parameters and failure sends REQUEST_ERROR. Reply::Resolve invokes a deferred producer synchronously, so the producer must start any slow authorization, I/O, or other asynchronous work itself. Completion is queued back through the transport. The request and its stream may disappear before deferred completion, in which case no response is sent.

Parameters
paramsBorrowed updated parameters, valid only for this callback.
Returns
Immediate or deferred acknowledgement.
Exceptions
messages::ProtocolViolationExceptionif the update is invalid for this request.

Implemented in quicr::TrackStatusHandler, quicr::SubscribeTrackHandler, quicr::SubscribeNamespaceHandler, quicr::PublishTrackHandler, and quicr::PublishNamespaceHandler.

◆ SetRequestId()

void quicr::TrackHandler::SetRequestId ( std::optional< uint64_t >  request_id)
inline

Sets or clears the connection-scoped request ID.

Parameters
request_idRequest ID assigned by the session, or std::nullopt when unbound.
Note
Thread-safe with request-stream installation and removal.

◆ SetTransport()

void quicr::TrackHandler::SetTransport ( std::shared_ptr< Session >  transport)
protected

Sets the session used for control and data operations.

Parameters
transportSession retained weakly; passing null clears effective access.
Note
The caller must keep the session alive independently.

Member Data Documentation

◆ binding_operation_mutex_

std::mutex quicr::TrackHandler::binding_operation_mutex_
protected

◆ full_track_name_

FullTrackName quicr::TrackHandler::full_track_name_
protected

Full track identity retained for the handler's lifetime.


The documentation for this class was generated from the following file: