--- a/rust/hedgewars-server/src/server/network.rs Sat Feb 02 15:06:39 2019 +0300
+++ b/rust/hedgewars-server/src/server/network.rs Mon Feb 04 19:22:21 2019 +0300
@@ -327,9 +327,10 @@
entry.insert(client);
}
- fn flush_server_messages(&mut self) {
- debug!("{} pending server messages", self.server.output.len());
- for (clients, message) in self.server.output.drain(..) {
+ fn flush_server_messages(&mut self, mut response: handlers::Response) {
+ debug!("{} pending server messages", response.len());
+ let output = response.extract_messages(&mut self.server);
+ for (clients, message) in output {
debug!("Message {:?} to {:?}", message, clients);
let msg_string = message.to_raw_protocol();
for client_id in clients {
@@ -377,7 +378,7 @@
self.create_client_socket(client_socket)?,
addr,
);
- self.flush_server_messages();
+ //TODO: create response for initial messages
Ok(())
}
@@ -432,7 +433,9 @@
)?,
}
- self.flush_server_messages();
+ if !response.is_empty() {
+ self.flush_server_messages(response);
+ }
if !self.server.removed_clients.is_empty() {
let ids: Vec<_> = self.server.removed_clients.drain(..).collect();