1use stray::StatusNotifierWatcher;
2use tokio::join;
3use tokio::sync::mpsc;
4
5#[tokio::main]
6async fn main() -> stray::error::Result<()> {
7 let (_cmd_tx, cmd_rx) = mpsc::channel(10);
8 let tray = StatusNotifierWatcher::new(cmd_rx).await?;
9
10 let mut host_one = tray.create_notifier_host("host_one").await.unwrap();
11 let mut host_two = tray.create_notifier_host("host_two").await.unwrap();
12
13 let one = tokio::spawn(async move {
14 while let Ok(mesage) = host_one.recv().await {
15 println!("Message from host one {:?}", mesage);
16 }
17 });
18
19 let two = tokio::spawn(async move {
20 let mut count = 0;
21 while let Ok(mesage) = host_two.recv().await {
22 count += 1;
23 if count > 5 {
24 break;
25 }
26 println!("Message from host two {:?}", mesage);
27 }
28
29 host_two.destroy().await?;
30 stray::error::Result::<()>::Ok(())
31 });
32
33 let _ = join!(one, two);
34 Ok(())
35}