LibQuicR
quicr::Session::Callbacks Struct Reference

Callback interface for session events common to both client and server mode. More...

#include <session_callbacks.h>

Inheritance diagram for quicr::Session::Callbacks:
quicr::Session::ClientCallbacks quicr::Session::ServerCallbacks

Public Member Functions

virtual ~Callbacks ()=default
 Destroy the callback interface. More...
 
virtual Expected< void, Error< ErrorCode > > SetupReceived (const std::shared_ptr< Session > &session, const SetupAttributes &setup_attributes)
 Callback on receipt of the peer's SETUP message. More...
 
virtual void OnStreamClosed (std::uint64_t stream_id, StreamClosedFlag flag)
 Notify that a QUIC stream closed. More...
 
virtual void StatusChanged (const std::shared_ptr< Session > &session, Status status)
 Callback notification for status/state change. More...
 
virtual void MetricsSampled (const std::shared_ptr< Session > &session, const ConnectionMetrics &metrics)
 Notification callback to provide sampled connection metrics. More...
 
virtual Reply< const PublishResponse, PublishErrorCode > PublishReceived (const std::shared_ptr< Session > &session, std::uint64_t request_id, const PublishAttributes &publish_attributes, std::weak_ptr< SubscribeNamespaceHandler > sub_ns_handler)
 Callback notification for new publish received. More...
 
virtual Reply< void, PublishNamespaceErrorCode > PublishNamespaceReceived (const std::shared_ptr< Session > &session, const TrackNamespace &track_namespace, const PublishNamespaceAttributes &publish_namespace_attributes)
 Callback notification for announce received by subscribe namespace. More...
 
virtual Reply< const FetchResponse, FetchErrorCode > StandaloneFetchReceived (const std::shared_ptr< Session > &session, std::uint64_t request_id, const FullTrackName &track_full_name, const StandaloneFetchAttributes &attributes)
 Event to run on receiving a Standalone Fetch request. More...
 
virtual Reply< const FetchResponse, FetchErrorCode > JoiningFetchReceived (const std::shared_ptr< Session > &session, std::uint64_t request_id, const FullTrackName &track_full_name, const JoiningFetchAttributes &attributes)
 Event to run on receiving a Joining Fetch request. More...
 
virtual Reply< void, FetchErrorCode > FetchCancelReceived (const std::shared_ptr< Session > &session, std::uint64_t request_id)
 Callback notification on receiving a FetchCancel message. More...
 
virtual Reply< TrackStatusResponse, RequestErrorCode > TrackStatusReceived (const std::shared_ptr< Session > &session, const FullTrackName &track_full_name)
 Callback notification for track status message received. More...
 

Detailed Description

Callback interface for session events common to both client and server mode.

Callbacks that answer an inbound request return a Reply, which carries either the response or a reason code for rejecting it. The session sends the protocol message from that reply and correlates it with the request itself, so there is nothing further for the application to call and no request identifier for it to keep.

Return a value to accept, or an Unexpected<Error<E>> holding a reason code, optional reason string, and optional redirect to reject. A Reply<void, E> accepts by returning {}.

An answer that cannot be given straight away is deferred with Reply::Defer(). Its producer is called on the session's message-handling thread and must start, rather than perform, slow work there. When that work completes, invoking the supplied completion callback marshals the response back to the transport notification thread.

Callbacks are invoked on the transport notify thread, which also carries stream and connection events, so an immediate reply must return promptly; anything slow belongs in a deferred one. Each reply is answered exactly once. The transport catches exceptions that escape the producer while it is invoked or the continuation after it is queued; either case can leave the request unanswered until the peer times it out. Exceptions on an application-created worker thread remain the application's responsibility.

A callback that is not overridden keeps its default, given per method below.

Constructor & Destructor Documentation

◆ ~Callbacks()

virtual quicr::Session::Callbacks::~Callbacks ( )
virtualdefault

Destroy the callback interface.

Member Function Documentation

◆ FetchCancelReceived()

virtual Reply<void, FetchErrorCode> quicr::Session::Callbacks::FetchCancelReceived ( const std::shared_ptr< Session > &  session,
std::uint64_t  request_id 
)
virtual

Callback notification on receiving a FetchCancel message.

Parameters
request_idRequest ID received.
sessionSession that received the cancellation.
Returns
Immediate or deferred acknowledgment, or error.

◆ JoiningFetchReceived()

virtual Reply<const FetchResponse, FetchErrorCode> quicr::Session::Callbacks::JoiningFetchReceived ( const std::shared_ptr< Session > &  session,
std::uint64_t  request_id,
const FullTrackName &  track_full_name,
const JoiningFetchAttributes &  attributes 
)
virtual

Event to run on receiving a Joining Fetch request.

Defaults to rejecting with kInternalError, since fetch is not served unless implemented.

Parameters
request_idRequest ID received.
sessionSession that received the request.
track_full_nameTrack full name
attributesFetch attributes received.
Returns
Immediate or deferred fetch response, or rejection reason.

◆ MetricsSampled()

virtual void quicr::Session::Callbacks::MetricsSampled ( const std::shared_ptr< Session > &  session,
const ConnectionMetrics &  metrics 
)
virtual

Notification callback to provide sampled connection metrics.

Invoked every Config::metrics_sample_ms in either client or server mode. The period based metrics reset after this callback, so a value not read here is lost. Per track metrics for the same period follow this call, via PublishTrackHandler::MetricsSampled and SubscribeTrackHandler::MetricsSampled, sharing the same last_sample_time.

Invoked on the transport notify thread, which also carries stream and connection events. Return promptly; a slow implementation backs the queue up and other notifications are dropped to make room.

Parameters
sessionThe session the metrics belong to
metricsCopy of the connection metrics for the sample period

◆ OnStreamClosed()

virtual void quicr::Session::Callbacks::OnStreamClosed ( std::uint64_t  stream_id,
StreamClosedFlag  flag 
)
virtual

Notify that a QUIC stream closed.

Parameters
stream_idIdentifier of the closed stream.
flagEvent that closed the stream direction.

Reimplemented in quicr::Session::ServerCallbacks.

◆ PublishNamespaceReceived()

virtual Reply<void, PublishNamespaceErrorCode> quicr::Session::Callbacks::PublishNamespaceReceived ( const std::shared_ptr< Session > &  session,
const TrackNamespace &  track_namespace,
const PublishNamespaceAttributes &  publish_namespace_attributes 
)
virtual

Callback notification for announce received by subscribe namespace.

Client mode only. Called when a PUBLISH_NAMESPACE is received for a subscribed prefix.

Parameters
track_namespaceTrack namespace
sessionSession that received the request.
publish_namespace_attributesPublish announce attributes received
Returns
Immediate or deferred success, or rejection reason.

◆ PublishReceived()

virtual Reply<const PublishResponse, PublishErrorCode> quicr::Session::Callbacks::PublishReceived ( const std::shared_ptr< Session > &  session,
std::uint64_t  request_id,
const PublishAttributes &  publish_attributes,
std::weak_ptr< SubscribeNamespaceHandler >  sub_ns_handler 
)
virtual

Callback notification for new publish received.

Return the publish response to accept. Defaults to rejecting with kNotSupported.

Parameters
request_idIncoming publish request ID
sessionSession that received the request.
publish_attributesAttributes of the publish
sub_ns_handlerMatching subscribe namespace handler, if any
Returns
Immediate or deferred acceptance response, or rejection reason.

◆ SetupReceived()

virtual Expected<void, Error<ErrorCode> > quicr::Session::Callbacks::SetupReceived ( const std::shared_ptr< Session > &  session,
const SetupAttributes &  setup_attributes 
)
virtual

Callback on receipt of the peer's SETUP message.

Returning an error disconnects the session.

Parameters
sessionThe session receiving SETUP
setup_attributesPeer setup attributes received
Returns
Success to continue setup, or an error that disconnects the session.
Examples
simple_publish/main.cpp, and simple_subscribe/main.cpp.

◆ StandaloneFetchReceived()

virtual Reply<const FetchResponse, FetchErrorCode> quicr::Session::Callbacks::StandaloneFetchReceived ( const std::shared_ptr< Session > &  session,
std::uint64_t  request_id,
const FullTrackName &  track_full_name,
const StandaloneFetchAttributes &  attributes 
)
virtual

Event to run on receiving a Standalone Fetch request.

Defaults to rejecting with kInternalError, since fetch is not served unless implemented.

Parameters
request_idRequest ID received.
sessionSession that received the request.
track_full_nameTrack full name
attributesFetch attributes received.
Returns
Immediate or deferred fetch response, or rejection reason.

◆ StatusChanged()

virtual void quicr::Session::Callbacks::StatusChanged ( const std::shared_ptr< Session > &  session,
Status  status 
)
virtual

Callback notification for status/state change.

Callback notification indicates state change of connection, such as disconnected. May be invoked in either client or server mode.

Parameters
sessionThe session whose status changed
statusChanged Status value

◆ TrackStatusReceived()

virtual Reply<TrackStatusResponse, RequestErrorCode> quicr::Session::Callbacks::TrackStatusReceived ( const std::shared_ptr< Session > &  session,
const FullTrackName &  track_full_name 
)
virtual

Callback notification for track status message received.

Defaults to accepting with an empty TrackStatusResponse.

Parameters
track_full_nameTrack full name
sessionSession that received the query.
Returns
Immediate or deferred status response, or rejection reason.

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