server can now send error messages to clients

This commit is contained in:
Mark
2023-10-24 22:50:21 +02:00
parent 94df757f0c
commit 1eee22bb4b
10 changed files with 370 additions and 93 deletions

View File

@@ -232,7 +232,14 @@ impl Database {
Ok(())
}
pub fn apply_command(&mut self, command: Command) {
pub fn apply_command(&mut self, mut command: Command) {
if !self.is_client() {
if let Command::ErrorInfo(t, _) = &mut command {
// clients can send ErrorInfo to the server and it will show up on other clients,
// BUT only the server can set the Title of the ErrorInfo.
t.clear();
}
}
// since db.update_endpoints is empty for clients, this won't cause unwanted back and forth
self.broadcast_update(&command);
match command {
@@ -349,6 +356,7 @@ impl Database {
Command::InitComplete => {
self.client_is_init = true;
}
Command::ErrorInfo(..) => {}
}
}
}

View File

@@ -154,7 +154,7 @@ impl Song {
{
Ok(data) => Some(data),
Err(e) => {
eprintln!("[info] error loading song {id}: {e}");
eprintln!("[WARN] error loading song {id}: {e}");
None
}
}