pub async fn advertise(
config: ClientConfig,
sink: Box<dyn Sink>,
) -> Result<(ClientHandle, EventStream)>Expand description
Advertises this client and serves the servers that connect to it.
The advertisement is published before this returns, so a caller learns about a backend that cannot publish instead of running a listener nobody can find. The port in the record is the one that was actually bound, which is how a listen address with port zero becomes reachable.
One server is admitted at a time: while a session is live the loop runs it, and when it ends
the client reports Event::Disconnected with a retry_in of zero - it schedules nothing,
because the next connection is the server’s decision - and accepts the next one. The
advertisement is withdrawn when the handle or the event stream is dropped, when
ClientHandle::close is called, or when the audio sink fails.
§Errors
Returns an error for an invalid configuration, for a configuration without
ClientConfig::inbound, for a Storage that cannot hold the
pairing PSK, for a listen address this build cannot bind, and for a backend that refuses the
advertisement.
§Panics
Panics when called outside a Tokio runtime, because the listener is spawned.
Pairing records come from ClientConfig::storage; this revision has no advertising
counterpart to connect_with_psks.