pub struct ClientHandle { /* private fields */ }Expand description
A live connection.
The connection reconnects on its own after a drop, so the handle and the event stream outlive
an individual session. Dropping the handle or the event stream ends it; ClientHandle::finished
waits without ending it.
Implementations§
Source§impl ClientHandle
impl ClientHandle
Sourcepub fn control(&self) -> ControlHandle
pub fn control(&self) -> ControlHandle
Returns a handle for the playback controls of this connection.
The handle is a cheap clone; every copy controls the same connection.
Sourcepub fn close(&mut self, reason: GoodbyeReason)
pub fn close(&mut self, reason: GoodbyeReason)
Stops the connection after telling the server why.
The reason is sent as client/goodbye on the live connection before it closes; a client
that is reconnecting has no connection to say it on. The goodbye is best effort: a write
that fails neither turns the close into an error nor schedules another attempt. Dropping
the handle does the same with GoodbyeReason::Shutdown.
Sourcepub async fn finished(self) -> Result<()>
pub async fn finished(self) -> Result<()>
Waits for the connection to end and returns its outcome.
The connection ends when the handle or the event stream is dropped, when
ClientHandle::close is called, or when the audio sink fails; a dropped session is
reconnected, not returned. Awaiting this keeps the handle alive, so dropping the event
stream is the usual way to stop.