Browse Source

user iid added to broadcast msg

master
Andrew Onuchowski 1 year ago
parent
commit
352c6ecffd
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      src/bin/connection_pool.rs

+ 6
- 1
src/bin/connection_pool.rs View File

@@ -46,9 +46,14 @@ impl ConnectionPool{

pub fn broadcast(&self, sender_iid: &u32, msg: &String) {
let mut del_conns: Vec<u32> = Vec::new();
let mut msg1: String;

msg1 = format!("User {sender_iid}: ").parse().unwrap();
msg1.push_str(msg);

for (iid, mut conn) in self.conns.lock().unwrap().iter() {
if sender_iid.ne(iid){
if conn.write_all(msg.as_bytes()).is_err() {
if conn.write_all(msg1.as_bytes()).is_err() {
del_conns.push(*iid);
continue;
}

Loading…
Cancel
Save