rearranged setup variables
This commit is contained in:
parent
bead4a5b99
commit
6a2d56b0bc
1 changed files with 10 additions and 3 deletions
13
src/main.rs
13
src/main.rs
|
@ -1,4 +1,4 @@
|
|||
use std::{time::Duration};
|
||||
use std::{time::Duration, thread};
|
||||
use crossbeam_channel::unbounded;
|
||||
|
||||
use modules::{socket_handler::Socket, stream_states::stream_states_class::StreamState, message_handler::{MessageHandler}};
|
||||
|
@ -20,15 +20,21 @@ const SERVER_ADDRESS: &str = "10.0.0.168:5000";
|
|||
fn main() {
|
||||
let mut state = StreamState::new();
|
||||
|
||||
let socket_listener = Socket::make_listener(SERVER_ADDRESS);
|
||||
let (control_c_flag_tx, control_c_called_flag_rx) = sync_flag::new_syncflag(false);
|
||||
let (from_socket_tx, from_socket_rx) = unbounded::<String>();
|
||||
let hotkey_channel_tx = from_socket_tx.clone();
|
||||
|
||||
let socket_listener = Socket::make_listener(SERVER_ADDRESS);
|
||||
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();
|
||||
socket.send("this is a message".to_string());
|
||||
|
||||
let hotkey_handle = thread::spawn(move || {
|
||||
modules::hotkey_handler::create_keyboard_hooks(hotkey_channel_tx);
|
||||
});
|
||||
|
||||
//until control_c is caught, check the queue of incoming
|
||||
//requests from the socket handler.
|
||||
|
@ -46,6 +52,7 @@ fn main() {
|
|||
}
|
||||
|
||||
socket.close();
|
||||
hotkey_handle.join();
|
||||
}
|
||||
|
||||
fn setup_control_c(mut control_c_flag_tx: sync_flag::SyncFlagTx) {
|
||||
|
|
Loading…
Reference in a new issue