mirror of
https://github.com/actix/examples
synced 2024-11-23 22:41:07 +01:00
Merge pull request #289 from BartWillems/master
Remove unwraps from websocket-chat
This commit is contained in:
commit
32d821d321
@ -117,7 +117,10 @@ impl Handler<Connect> for ChatServer {
|
|||||||
self.sessions.insert(id, msg.addr);
|
self.sessions.insert(id, msg.addr);
|
||||||
|
|
||||||
// auto join session to Main room
|
// auto join session to Main room
|
||||||
self.rooms.get_mut(&"Main".to_owned()).unwrap().insert(id);
|
self.rooms
|
||||||
|
.entry("Main".to_owned())
|
||||||
|
.or_insert(HashSet::new())
|
||||||
|
.insert(id);
|
||||||
|
|
||||||
// send id back
|
// send id back
|
||||||
id
|
id
|
||||||
@ -193,10 +196,11 @@ impl Handler<Join> for ChatServer {
|
|||||||
self.send_message(&room, "Someone disconnected", 0);
|
self.send_message(&room, "Someone disconnected", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.rooms.get_mut(&name).is_none() {
|
self.rooms
|
||||||
self.rooms.insert(name.clone(), HashSet::new());
|
.entry(name.clone())
|
||||||
}
|
.or_insert(HashSet::new())
|
||||||
|
.insert(id);
|
||||||
|
|
||||||
self.send_message(&name, "Someone connected", id);
|
self.send_message(&name, "Someone connected", id);
|
||||||
self.rooms.get_mut(&name).unwrap().insert(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user