diff --git a/src/main.rs b/src/main.rs index ec67a8f..b87758b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -111,7 +111,16 @@ fn play_sound(sound: String) { let device = rodio::default_output_device().unwrap(); let file = File::open(format!("sounds/{}.wav", sound)).unwrap(); let source = rodio::Decoder::new(BufReader::new(file)).unwrap(); - rodio::play_raw(&device, source.convert_samples()); + + if sound == "factorywhistle" { + rodio::play_raw(&device, source.amplify(1.5).convert_samples()); + } + else if sound == "cheer" { + rodio::play_raw(&device, source.amplify(0.7).convert_samples()); + } + else { + rodio::play_raw(&device, source.convert_samples()); + } } /** @@ -148,12 +157,17 @@ fn countdown(time_left: Duration, state: SafeState) { } async fn handle_websocket(state: SafeState, raw_stream: TcpStream, addr: SocketAddr) { - println!("Incoming TCP connection from: {}", addr); + info!("Incoming TCP connection from: {}", addr); let ws_stream = async_tungstenite::accept_async(raw_stream) - .await - .expect("Error during the websocket handshake occurred"); - println!("WebSocket connection established: {}", addr); + .await; + + if ws_stream.is_err() { + error!("Failed to accept connection: {:?}", ws_stream); + return; + } + let ws_stream = ws_stream.unwrap(); + info!("WebSocket connection established: {}", addr); // Insert the write part of this peer to the peer map. let (tx, rx) = unbounded();