rust/hedgewars-server/src/server/network.rs
changeset 15989 fb389df02e3e
parent 15939 4a8e6f9d5133
child 15990 c40f5e27aaf0
equal deleted inserted replaced
15988:0b2e0a7d0431 15989:fb389df02e3e
   178                     }
   178                     }
   179                 }
   179                 }
   180                 client_message = Self::read(&mut self.stream, &mut self.decoder) => {
   180                 client_message = Self::read(&mut self.stream, &mut self.decoder) => {
   181                      match client_message {
   181                      match client_message {
   182                         Ok(message) => {
   182                         Ok(message) => {
       
   183                             //todo!("add flood stats");
   183                             if !sender.send(Message(message)).await {
   184                             if !sender.send(Message(message)).await {
   184                                 break;
   185                                 break;
   185                             }
   186                             }
   186                         }
   187                         }
   187                         Err(e) => {
   188                         Err(e) => {
   188                             todo!("send cmdline errors");
   189                             //todo!("send cmdline errors");
   189                             sender.send(Error(format!("{}", e))).await;
   190                             sender.send(Error(format!("{}", e))).await;
   190                             if matches!(e, ProtocolError::Timeout) {
   191                             if matches!(e, ProtocolError::Timeout) {
   191                                 Self::write(&mut self.stream, Bytes::from(HwServerMessage::Bye("Ping timeout".to_string()).to_raw_protocol())).await;
   192                                 Self::write(&mut self.stream, Bytes::from(HwServerMessage::Bye("Ping timeout".to_string()).to_raw_protocol())).await;
   192                             }
   193                             }
   193                             break;
   194                             break;
   272                 }
   273                 }
   273                 None => unreachable!(),
   274                 None => unreachable!(),
   274             }
   275             }
   275         }
   276         }
   276 
   277 
   277         todo!("add the DB task");
   278         //todo!("add the DB task");
   278         todo!("add certfile watcher task");
   279         //todo!("add certfile watcher task");
   279         loop {
   280         loop {
   280             #[cfg(not(feature = "tls-connections"))]
   281             #[cfg(not(feature = "tls-connections"))]
   281             tokio::select! {
   282             tokio::select! {
   282                 Ok(value) = self.listener.accept() => accept_plain_branch(self, value, update_tx.clone()).await,
   283                 Ok(value) = self.listener.accept() => accept_plain_branch(self, value, update_tx.clone()).await,
   283                 client_message = update_rx.recv(), if !self.clients.is_empty() => client_message_branch(self, client_message).await
   284                 client_message = update_rx.recv(), if !self.clients.is_empty() => client_message_branch(self, client_message).await