more things
This commit is contained in:
parent
f760680e8b
commit
6134ef8843
2 changed files with 23 additions and 5 deletions
|
@ -58,7 +58,17 @@ impl MessageHandler for StreamState {
|
||||||
return (Some(update), Some(instructions));
|
return (Some(update), Some(instructions));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
StateUpdate::TimerCanRun(value) => {self.timer_can_run = value; return (Some(update), None)},
|
StateUpdate::TimerCanRun(value) => {
|
||||||
|
self.timer_can_run = value;
|
||||||
|
self.timer_start = SystemTime::now();
|
||||||
|
if value {
|
||||||
|
let mut instruction = Vec::new();
|
||||||
|
instruction.push(StateUpdate::TimerText(String::from("0.0")));
|
||||||
|
return (Some(update), Some(instruction))
|
||||||
|
} else {
|
||||||
|
return (Some(update), None);
|
||||||
|
}
|
||||||
|
}
|
||||||
StateUpdate::TimerLength(value) => {self.timer_length = value; return (Some(update), None)},
|
StateUpdate::TimerLength(value) => {self.timer_length = value; return (Some(update), None)},
|
||||||
StateUpdate::TimerText(value) => {self.timer_text = value.clone(); return (Some(StateUpdate::TimerText(value)), None)},
|
StateUpdate::TimerText(value) => {self.timer_text = value.clone(); return (Some(StateUpdate::TimerText(value)), None)},
|
||||||
StateUpdate::SubScene(value) => {
|
StateUpdate::SubScene(value) => {
|
||||||
|
@ -79,6 +89,14 @@ impl MessageHandler for StreamState {
|
||||||
StateUpdate::Scene(value) => {
|
StateUpdate::Scene(value) => {
|
||||||
hotkey_handler.change_scene(value, None);
|
hotkey_handler.change_scene(value, None);
|
||||||
self.current_scene = value;
|
self.current_scene = value;
|
||||||
|
|
||||||
|
if value == Scenes::Screen {
|
||||||
|
self.timer_start = SystemTime::now();
|
||||||
|
self.timer_finished = false;
|
||||||
|
} else {
|
||||||
|
self.timer_finished = true;
|
||||||
|
}
|
||||||
|
|
||||||
return (Some(update), None);
|
return (Some(update), None);
|
||||||
},
|
},
|
||||||
StateUpdate::StreamSoundToggleOn(value) => {hotkey_handler.toggle_stream_sound(value); return (Some(update), None)},
|
StateUpdate::StreamSoundToggleOn(value) => {hotkey_handler.toggle_stream_sound(value); return (Some(update), None)},
|
||||||
|
@ -92,7 +110,7 @@ impl MessageHandler for StreamState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tick(&mut self) -> (Option<StateUpdate>, Option<StateUpdate>) {
|
fn tick(&mut self) -> (Option<StateUpdate>, Option<StateUpdate>) {
|
||||||
if self.timer_finished == false {
|
if self.timer_finished == false && self.timer_can_run == true {
|
||||||
let change = self.timer_start.elapsed();
|
let change = self.timer_start.elapsed();
|
||||||
match change {
|
match change {
|
||||||
Err(_) => {(None, None)},
|
Err(_) => {(None, None)},
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl Socket {
|
||||||
|
|
||||||
pub fn handle_client(stream: Arc<TcpStream>, update_tx: Sender<String>, program_shutdown_flag: sync_flag::SyncFlagRx) {
|
pub fn handle_client(stream: Arc<TcpStream>, update_tx: Sender<String>, program_shutdown_flag: sync_flag::SyncFlagRx) {
|
||||||
let mut buffer = [0; 1024];
|
let mut buffer = [0; 1024];
|
||||||
stream.set_read_timeout(Some(Duration::from_millis(100))).expect("Could not set a read timeout");
|
stream.set_read_timeout(Some(Duration::from_millis(10))).expect("Could not set a read timeout");
|
||||||
while program_shutdown_flag.get() {
|
while program_shutdown_flag.get() {
|
||||||
match stream.as_ref().read(&mut buffer) {
|
match stream.as_ref().read(&mut buffer) {
|
||||||
Err(_) => {},
|
Err(_) => {},
|
||||||
|
@ -85,11 +85,11 @@ impl Socket {
|
||||||
let mut tx = streams.get(i).unwrap().as_ref();
|
let mut tx = streams.get(i).unwrap().as_ref();
|
||||||
|
|
||||||
match tx.write(message.clone().as_bytes()) {
|
match tx.write(message.clone().as_bytes()) {
|
||||||
Err(_) => {streams.remove(i); continue;},
|
Err(_) => {streams.remove(i); println!("removed a socket"); continue;},
|
||||||
Ok(_) => {},
|
Ok(_) => {},
|
||||||
}
|
}
|
||||||
|
tx.write(b"\n").unwrap();
|
||||||
tx.flush().unwrap();
|
tx.flush().unwrap();
|
||||||
println!("sent");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue