mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
remove select macro from echo example
This commit is contained in:
@ -29,7 +29,7 @@ async fn chat_route(
|
||||
WsChatSession {
|
||||
id: 0,
|
||||
hb: Instant::now(),
|
||||
room: "Main".to_owned(),
|
||||
room: "main".to_owned(),
|
||||
name: None,
|
||||
addr: srv.get_ref().clone(),
|
||||
},
|
||||
|
@ -66,7 +66,7 @@ impl Default for ChatServer {
|
||||
fn default() -> ChatServer {
|
||||
// default room
|
||||
let mut rooms = HashMap::new();
|
||||
rooms.insert("Main".to_owned(), HashSet::new());
|
||||
rooms.insert("main".to_owned(), HashSet::new());
|
||||
|
||||
ChatServer {
|
||||
sessions: HashMap::new(),
|
||||
@ -108,14 +108,14 @@ impl Handler<Connect> for ChatServer {
|
||||
println!("Someone joined");
|
||||
|
||||
// notify all users in same room
|
||||
self.send_message("Main", "Someone joined", 0);
|
||||
self.send_message("main", "Someone joined", 0);
|
||||
|
||||
// register session with random id
|
||||
let id = self.rng.gen::<usize>();
|
||||
self.sessions.insert(id, msg.addr);
|
||||
|
||||
// auto join session to Main room
|
||||
self.rooms.get_mut(&"Main".to_owned()).unwrap().insert(id);
|
||||
// auto join session to main room
|
||||
self.rooms.get_mut("main").unwrap().insert(id);
|
||||
|
||||
// send id back
|
||||
id
|
||||
|
@ -147,7 +147,7 @@ impl ChatSession {
|
||||
id: 0,
|
||||
addr,
|
||||
hb: Instant::now(),
|
||||
room: "Main".to_owned(),
|
||||
room: "main".to_owned(),
|
||||
framed,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user