pub struct Session { /* private fields */ }Expand description
A relay session: the requests of moqt::client::Session, through
Deref, with its token kept fresh. It follows GOAWAY and replaces a lost
connection for up to 60 s, sending its namespaces and subscriptions
again; when it cannot, the session ends with SessionEnd::ConnectionLost.
Implementations§
Methods from Deref<Target = Session>§
pub fn moqt_session(&self) -> &Arc<Session> ⓘ
pub fn moqt_session(&self) -> &Arc<Session> ⓘ
The wrapped session, for what this type does not cover; its events are not for the caller.
pub fn origin(&self) -> &Origin
pub fn origin(&self) -> &Origin
The tracks publish_track registered, which a handler may write into
as well.
pub fn add_handler(&self, handler: Arc<dyn EventHandler>) -> HandlerId
pub fn add_handler(&self, handler: Arc<dyn EventHandler>) -> HandlerId
Hands the session’s events to handler before the Origin, after
the handlers added earlier.
pub fn remove_handler(&self, id: HandlerId)
pub async fn subscribe(
&self,
namespace: &[impl AsRef<str>],
track: &str,
options: SubscribeOptions,
) -> Result<Subscription, RequestError>
pub async fn subscribe( &self, namespace: &[impl AsRef<str>], track: &str, options: SubscribeOptions, ) -> Result<Subscription, RequestError>
SUBSCRIBE (draft-14 §9.7).
pub async fn subscribe_current_group(
&self,
namespace: &[impl AsRef<str>],
track: &str,
options: GroupStartOptions,
) -> Result<Subscription, RequestError>
pub async fn subscribe_current_group( &self, namespace: &[impl AsRef<str>], track: &str, options: GroupStartOptions, ) -> Result<Subscription, RequestError>
Subscribes and reads the group the largest object is in from its first object, through a Joining FETCH (draft-14 §9.16.2).
pub async fn subscribe_group_start(
&self,
namespace: &[impl AsRef<str>],
track: &str,
new_group_after: u64,
options: GroupStartOptions,
) -> Result<Subscription, RequestError>
pub async fn subscribe_group_start( &self, namespace: &[impl AsRef<str>], track: &str, new_group_after: u64, options: GroupStartOptions, ) -> Result<Subscription, RequestError>
Subscribes and reads the track from the first object of a group
(draft-18 §5.1.3.1), chosen once the SUBSCRIBE_OK arrives: the
current group, through a Joining FETCH, or, when the track has
dynamic groups and its largest object ID is new_group_after or
more, a new group it asks the publisher to start (NEW_GROUP_REQUEST,
§10.2.13).
pub async fn fetch(
&self,
namespace: &[impl AsRef<str>],
track: &str,
start: Location,
end: Location,
) -> Result<Fetch, FetchError>
pub async fn fetch( &self, namespace: &[impl AsRef<str>], track: &str, start: Location, end: Location, ) -> Result<Fetch, FetchError>
A Standalone FETCH (draft-14 §9.16.1). end’s object is the last
object plus 1, and 0 means the whole group. Returns once the response
stream has arrived.
pub async fn track_status(
&self,
namespace: &[impl AsRef<str>],
track: &str,
) -> Result<Option<Location>, RequestError>
pub async fn track_status( &self, namespace: &[impl AsRef<str>], track: &str, ) -> Result<Option<Location>, RequestError>
TRACK_STATUS (draft-14 §9.20): the track’s largest location, or
None while it has none.
pub async fn watch_namespaces(
&self,
prefix: &[impl AsRef<str>],
) -> Result<NamespaceWatch, RequestError>
pub async fn watch_namespaces( &self, prefix: &[impl AsRef<str>], ) -> Result<NamespaceWatch, RequestError>
SUBSCRIBE_NAMESPACE (draft-14 §9.28) for the namespaces under
prefix. Fails when the SUBSCRIBE_NAMESPACE is rejected, as one whose
prefix overlaps another watch_namespaces, watch_tracks or
follow_track of this session is (NAMESPACE_PREFIX_OVERLAP).
pub async fn watch_tracks(
&self,
prefix: &[impl AsRef<str>],
) -> Result<TrackWatch, RequestError>
pub async fn watch_tracks( &self, prefix: &[impl AsRef<str>], ) -> Result<TrackWatch, RequestError>
SUBSCRIBE_NAMESPACE (draft-14 §9.28) for the namespaces under
prefix and their tracks: the watch reports each namespace and hands
over each PUBLISH under it, which nothing else on the session then
sees. Fails when the SUBSCRIBE_NAMESPACE is rejected, as one whose
prefix overlaps another watch_namespaces, watch_tracks or
follow_track of this session is (NAMESPACE_PREFIX_OVERLAP).
pub async fn follow_track(
&self,
namespace: &[impl AsRef<str>],
track: &str,
) -> Result<TrackFollower, RequestError>
pub async fn follow_track( &self, namespace: &[impl AsRef<str>], track: &str, ) -> Result<TrackFollower, RequestError>
Follows track in namespace as peers publish it one after another,
through a SUBSCRIBE_NAMESPACE (draft-14 §9.28) for the namespace and
its tracks; see TrackFollower. Fails when the SUBSCRIBE_NAMESPACE
is rejected, as one whose namespace overlaps another
watch_namespaces, watch_tracks or follow_track of this session
is (NAMESPACE_PREFIX_OVERLAP): one session follows one track per
namespace.
pub async fn announce(
&self,
namespace: &[impl AsRef<str>],
) -> Result<Announcement, RequestError>
pub async fn announce( &self, namespace: &[impl AsRef<str>], ) -> Result<Announcement, RequestError>
PUBLISH_NAMESPACE (draft-14 §9.23).
pub async fn publish_track(
&self,
namespace: &[impl AsRef<str>],
track: &str,
options: PublishTrackOptions,
) -> Result<TrackWriter, Error>
pub async fn publish_track( &self, namespace: &[impl AsRef<str>], track: &str, options: PublishTrackOptions, ) -> Result<TrackWriter, Error>
Registers a track to publish, whose group ids start at the wall-clock
time in µs, so a later run of the same publisher does not reuse a
location the relay still caches. A track registered again keeps its
objects, so once it has one, registering it with the other datagram
fails with PublishTrackError::OtherDelivery and changes nothing.
Also fails when the PUBLISH fails.
pub fn transferred_bytes(&self) -> TransferredBytes
pub async fn closed(&self) -> TransportClose
pub async fn closed(&self) -> TransportClose
Resolves once the session’s last connection has closed.
pub async fn close(&self)
pub async fn close(&self)
Stops answering the peer, ends every namespace watch, done and
next_subscriber, and closes the session with NO_ERROR, as
moqt::Session::close does.