s'more chat progress

This commit is contained in:
Rusty Striker 2024-10-01 22:16:35 +03:00
parent acf96db186
commit b4e6a3fe39
Signed by: RustyStriker
GPG key ID: 87E4D691632DFF15
5 changed files with 33 additions and 4 deletions

View file

@ -57,6 +57,15 @@ impl GameServer {
.collect();
_ = broadcast.send(api::Response::GetChatHistory(history));
},
api::Request::GetLastMessages { mut amount } => {
if amount == 0 { amount = self.chat.len(); }
let start = if amount >= self.chat.len() { self.chat.len() } else { self.chat.len() - amount };
let history: Vec<ChatMessage> = self.chat.iter()
.skip(start)
.map(|m| m.1.clone())
.collect();
_ = broadcast.send(api::Response::GetChatHistory(history));
},
}
}
_ = broadcast.send(api::Response::Shutdown);