feat(demo mode): allow for random color assignments
This commit is contained in:
19
src/lib.rs
19
src/lib.rs
@@ -23,15 +23,18 @@ pub type Observers = Arc<RwLock<HashMap<SocketAddr, UnboundedSender<Message>>>>;
|
||||
pub type Matches = Arc<RwLock<HashMap<u32, Arc<RwLock<Match>>>>>;
|
||||
pub type WrappedTournament = Arc<RwLock<Option<Arc<RwLock<dyn Tournament + Send + Sync>>>>>;
|
||||
|
||||
pub const SERVER_PLAYER_USERNAME: &str = "The Server";
|
||||
pub const SERVER_PLAYER_ADDR: &str = "127.0.0.1:6666";
|
||||
|
||||
pub async fn broadcast_message(observers: &Observers, addrs: &Vec<SocketAddr>, msg: &str) {
|
||||
for addr in addrs {
|
||||
let observers_guard = observers.read().await;
|
||||
let tx = observers_guard.get(addr);
|
||||
if tx.is_none() {
|
||||
continue;
|
||||
}
|
||||
let _ = send(tx.unwrap(), msg);
|
||||
}
|
||||
for addr in addrs {
|
||||
let observers_guard = observers.read().await;
|
||||
let tx = observers_guard.get(addr);
|
||||
if tx.is_none() {
|
||||
continue;
|
||||
}
|
||||
let _ = send(tx.unwrap(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn gen_match_id(matches: &Matches) -> u32 {
|
||||
|
||||
Reference in New Issue
Block a user