From cdb4799231837e1e1a07f484b0b8a944819e6e78 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Fri, 31 May 2019 04:57:08 +0200 Subject: Get rid of WarningGet rid of Warninss --- game_server/src/lobby.rs | 4 +++- game_server/src/scribble_group.rs | 2 +- game_server/src/server.rs | 14 ++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'game_server') diff --git a/game_server/src/lobby.rs b/game_server/src/lobby.rs index d03bd45..ef164af 100644 --- a/game_server/src/lobby.rs +++ b/game_server/src/lobby.rs @@ -9,6 +9,7 @@ pub struct Lobby { groups: HashMap>, } +#[allow(dead_code)] impl Lobby { pub fn new() -> Self { Self { @@ -21,7 +22,7 @@ impl Lobby { "scribble" => { Some(Box::new(ScribbleGroup::new(id, name.to_string()))) }, - other => None, + _ => None, } } @@ -48,6 +49,7 @@ impl Lobby { } } +#[allow(dead_code)] pub struct GroupIterator<'a> { groups: std::collections::hash_map::Values<'a, GroupId, Box> } diff --git a/game_server/src/scribble_group.rs b/game_server/src/scribble_group.rs index 2eb16f2..0d2c0f1 100644 --- a/game_server/src/scribble_group.rs +++ b/game_server/src/scribble_group.rs @@ -29,7 +29,7 @@ impl Group for ScribbleGroup { fn add_client(&mut self, id: UserId, client: GameClient) { debug!("user {} joined the group {}:'{}'", id, self.id, self.name); - let (sen, mut rec) = client.split(); + let (sen, rec) = client.split(); self.senders.lock().unwrap().insert(id, sen); let senders_mutex = self.senders.clone(); let self_uid = id; diff --git a/game_server/src/server.rs b/game_server/src/server.rs index ea33e2a..0b76f15 100644 --- a/game_server/src/server.rs +++ b/game_server/src/server.rs @@ -8,7 +8,6 @@ use websocket::{OwnedMessage, use std::net::{SocketAddr, ToSocketAddrs, TcpStream}; use std::sync::{mpsc, mpsc::{Sender, Receiver}}; -use std::collections::HashMap; use super::lobby::Lobby; use super::backend_connection::BackendConnection; @@ -121,16 +120,19 @@ impl GameServer { } fn read_clients(&self) -> Receiver { - let (s, r): (Sender, Receiver) + let (sen, rec): (Sender, Receiver) = mpsc::channel(); let addr = self.addr; std::thread::spawn(move || { - let result = Self::handle_requests(addr, &s).or_else(|e| s.send(Err(e))); + match Self::handle_requests(addr, &sen) { + Err(e) => sen.send(Err(e)).unwrap(), + _ => (), + } }); - r + rec } - fn handle_requests(addr: SocketAddr, s: &Sender) -> Result<(), GameServerError> { + fn handle_requests(addr: SocketAddr, sen: &Sender) -> Result<(), GameServerError> { let server = match Server::::bind(addr) { Ok(v) => v, Err(e) => { @@ -140,7 +142,7 @@ impl GameServer { }; info!("webserver is being launched"); for req in server { - s.send(Ok(Self::handle_request(req)?)).unwrap(); + sen.send(Ok(Self::handle_request(req)?)).unwrap(); } info!("webserver is being shut down"); Ok(()) -- cgit v1.2.3-70-g09d2