(&mut self, msg: Connect, _: &mut Context<Self>)
| 117 | type Result = u64; |
| 118 | |
| 119 | fn handle(&mut self, msg: Connect, _: &mut Context<Self>) -> Self::Result { |
| 120 | println!("Someone joined"); |
| 121 | |
| 122 | // notify all users in same room |
| 123 | self.send_message("main", "Someone joined", 0); |
| 124 | |
| 125 | // register session with random id |
| 126 | let id = rand::rng().random::<u64>(); |
| 127 | self.sessions.insert(id, msg.addr); |
| 128 | |
| 129 | // auto join session to main room |
| 130 | self.rooms.entry("main".to_owned()).or_default().insert(id); |
| 131 | |
| 132 | let count = self.visitor_count.fetch_add(1, Ordering::SeqCst); |
| 133 | self.send_message("main", &format!("Total visitors {count}"), 0); |
| 134 | |
| 135 | // send id back |
| 136 | id |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /// Handler for Disconnect message. |
nothing calls this directly
no test coverage detected