diff --git a/src/main.rs b/src/main.rs index 36a30f6..950b4f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,14 +18,13 @@ fn main() { let socket_listener = Socket::make_listener(SERVER_ADDRESS); let (from_socket_tx, from_socket_rx) = unbounded::(); - let (to_socket_tx, to_socket_rx) = unbounded::(); - let mut socket = Socket::handle_connections(socket_listener, from_socket_tx, to_socket_rx); + let mut socket = Socket::handle_connections(socket_listener, from_socket_tx); let (control_c_flag_tx, control_c_called_flag_rx) = sync_flag::new_syncflag(false); setup_control_c(control_c_flag_tx); let _outgoing = std::net::TcpStream::connect(SERVER_ADDRESS).unwrap(); - to_socket_tx.send("this is a message".to_string()).unwrap(); + socket.send("this is a message".to_string()); //until control_c is caught, check the queue of incoming //requests from the socket handler. while !control_c_called_flag_rx.get() { diff --git a/src/modules/stream_states/state_update.rs b/src/modules/stream_states/state_update.rs index 64544ea..b26509a 100644 --- a/src/modules/stream_states/state_update.rs +++ b/src/modules/stream_states/state_update.rs @@ -1,4 +1,3 @@ -use std::ops::Add; use super::enums::{SubScenes, Scenes, SlideChange}; use serde_json::Value; diff --git a/src/tests/socket_handler_tests.rs b/src/tests/socket_handler_tests.rs index abb3b82..faafe66 100644 --- a/src/tests/socket_handler_tests.rs +++ b/src/tests/socket_handler_tests.rs @@ -32,9 +32,8 @@ fn panic_no_listener() { fn can_handle_messages() { let listener = Socket::make_listener("localhost:5004"); let (tx_1, rx_1) = unbounded::(); - let (_stream_tx, stream_rx) = unbounded::(); - let mut socket = Socket::handle_connections(listener, tx_1, stream_rx); + let mut socket = Socket::handle_connections(listener, tx_1); let join_handle = std::thread::spawn(move || { let mut outgoing = std::net::TcpStream::connect("localhost:5004").unwrap(); @@ -54,9 +53,8 @@ fn can_handle_messages() { fn can_handle_delayed_messages() { let listener = Socket::make_listener("localhost:5005"); let (tx_1, rx_1) = unbounded::(); - let (_stream_tx, stream_rx) = unbounded::(); - let mut socket = Socket::handle_connections(listener, tx_1, stream_rx); + let mut socket = Socket::handle_connections(listener, tx_1); let mut outgoing = std::net::TcpStream::connect("localhost:5005").unwrap(); outgoing.write("this is a test1\n".as_bytes()).unwrap(); @@ -80,9 +78,8 @@ fn can_handle_delayed_messages() { fn can_send_and_receive_on_stream() { let listener = Socket::make_listener("localhost:5006"); let (tx_1, rx_1) = unbounded::(); - let (stream_tx, stream_rx) = unbounded::(); - let mut socket = Socket::handle_connections(listener, tx_1, stream_rx); + let mut socket = Socket::handle_connections(listener, tx_1); let mut outgoing = std::net::TcpStream::connect("localhost:5006").unwrap(); outgoing.set_read_timeout(Some(Duration::from_millis(1000))).expect("couln't set timout"); @@ -92,7 +89,7 @@ fn can_send_and_receive_on_stream() { thread::sleep(Duration::from_millis(250)); assert_eq!(rx_1.try_recv().unwrap(), "such a test!\n"); - stream_tx.send("this is another test!".to_string()).unwrap(); + socket.send("this is another test!".to_string()); thread::sleep(Duration::from_millis(250)); let mut buffer = [0; 256];