zoe_client/client/api/
secret.rs1use super::super::Client;
2use crate::{RelayConnectionStatus, client::ClientSecret};
3use eyeball::Subscriber;
4
5#[cfg(feature = "frb-api")]
6use flutter_rust_bridge::frb;
7
8#[cfg_attr(feature = "frb-api", frb)]
9impl Client {
10 pub fn client_secret(&self) -> ClientSecret {
12 self.client_secret_observable.get()
13 }
14}
15
16#[cfg_attr(feature = "frb-api", frb(ignore))]
17impl Client {
18 pub fn subscribe_to_client_secret(&self) -> Subscriber<ClientSecret> {
23 self.client_secret_observable.subscribe()
24 }
25
26 pub(crate) async fn update_client_secret_state(&self) {
28 let connected_servers = {
30 let info_map = self.relay_info.read().await;
31 info_map
32 .values()
33 .filter(|info| matches!(info.status, RelayConnectionStatus::Connected { .. }))
34 .map(|info| info.info.relay_address.clone())
35 .collect::<Vec<_>>()
36 };
37
38 let mut updated_client_secret = (*self.client_secret).clone();
40 updated_client_secret.servers = connected_servers;
41
42 self.client_secret_observable.set(updated_client_secret);
43 }
44}