diff --git a/websockets/chat-actorless/src/server.rs b/websockets/chat-actorless/src/server.rs index bbe0d8b..01f0262 100644 --- a/websockets/chat-actorless/src/server.rs +++ b/websockets/chat-actorless/src/server.rs @@ -87,7 +87,7 @@ impl ChatServer { /// Send message to users in a room. /// /// `skip` is used to prevent messages triggered by a connection also being received by it. - async fn send_system_message(&self, room: &str, skip: ConnId, msg: impl Into) { + async fn send_system_message(&self, room: &str, skip: ConnId, msg: impl Into) { if let Some(sessions) = self.rooms.get(room) { let msg = msg.into(); @@ -106,7 +106,7 @@ impl ChatServer { /// /// `conn` is used to find current room and prevent messages sent by a connection also being /// received by it. - async fn send_message(&self, conn: ConnId, msg: impl Into) { + async fn send_message(&self, conn: ConnId, msg: impl Into) { if let Some(room) = self .rooms .iter() @@ -124,7 +124,7 @@ impl ChatServer { self.send_system_message("main", 0, "Someone joined").await; // register session with random connection ID - let id = thread_rng().gen::(); + let id = thread_rng().gen::(); self.sessions.insert(id, tx); // auto join session to main room @@ -142,7 +142,7 @@ impl ChatServer { async fn disconnect(&mut self, conn_id: ConnId) { println!("Someone disconnected"); - let mut rooms: Vec = Vec::new(); + let mut rooms: Vec = Vec::new(); // remove sender if self.sessions.remove(&conn_id).is_some() { @@ -162,12 +162,12 @@ impl ChatServer { } /// Returns list of created room names. - fn list_rooms(&mut self) -> Vec { + fn list_rooms(&mut self) -> Vec { self.rooms.keys().cloned().collect() } /// Join room, send disconnect message to old room send join message to new room. - async fn join_room(&mut self, conn_id: ConnId, room: String) { + async fn join_room(&mut self, conn_id: ConnId, room: RoomId) { let mut rooms = Vec::new(); // remove session from all rooms @@ -230,7 +230,7 @@ pub struct ChatServerHandle { impl ChatServerHandle { /// Register client message sender and obtain connection ID. - pub async fn connect(&self, conn_tx: mpsc::UnboundedSender) -> ConnId { + pub async fn connect(&self, conn_tx: mpsc::UnboundedSender) -> ConnId { let (res_tx, res_rx) = oneshot::channel(); // unwrap: chat server should not have been dropped @@ -243,7 +243,7 @@ impl ChatServerHandle { } /// List all created rooms. - pub async fn list_rooms(&self) -> Vec { + pub async fn list_rooms(&self) -> Vec { let (res_tx, res_rx) = oneshot::channel(); // unwrap: chat server should not have been dropped @@ -254,7 +254,7 @@ impl ChatServerHandle { } /// Join `room`, creating it if it does not exist. - pub async fn join_room(&self, conn: ConnId, room: impl Into) { + pub async fn join_room(&self, conn: ConnId, room: impl Into) { let (res_tx, res_rx) = oneshot::channel(); // unwrap: chat server should not have been dropped @@ -271,7 +271,7 @@ impl ChatServerHandle { } /// Broadcast message to current room. - pub async fn send_message(&self, conn: ConnId, msg: impl Into) { + pub async fn send_message(&self, conn: ConnId, msg: impl Into) { let (res_tx, res_rx) = oneshot::channel(); // unwrap: chat server should not have been dropped