send — broadcast message. subscribe — create receiver.
send:
subscribe:
1use tokio::sync::broadcast;23let (tx, _) = broadcast::channel(16);4tx.send("hello").unwrap();56let mut rx1 = tx.subscribe();7let mut rx2 = tx.subscribe();89println!("{}", rx1.recv().await.unwrap()); // "hello"10println!("{}", rx2.recv().await.unwrap()); // "hello"
Key: send for broadcasting, subscribe for receiving.