got rid of delayed sending

This commit is contained in:
Nickiel12 2021-12-31 19:54:52 -08:00
parent 6b7edb7ce8
commit 23dceaf2ba
4 changed files with 9 additions and 17 deletions

View file

@ -86,6 +86,7 @@ impl Hotkeys {
}
pub fn change_scene(&self, scene: Scenes, sub_scene: Option<SubScenes>) {
println!("sending: {:?} : {:?}", scene, sub_scene);
let hotkey: &str;
if scene == Scenes::Augmented {
hotkey = self.hotkeys["hotkeys"]["obs"]["camera_scene_augmented"].as_str().unwrap()

View file

@ -95,9 +95,9 @@ impl MessageHandler for StreamState {
}
},
StateUpdate::Scene(value) => {
println!("{:?}", value);
if value == Scenes::Screen {
if self.current_scene != Scenes::Screen {
println!("ping");
self.timer_start = SystemTime::now();
self.timer_finished = false;
}
@ -106,7 +106,7 @@ impl MessageHandler for StreamState {
}
if self.current_scene != value {
match self.current_scene {
match value {
Scenes::Camera => {
hotkey_handler.change_scene(Scenes::Camera, Some(self.camera_sub_scene));
},
@ -114,6 +114,7 @@ impl MessageHandler for StreamState {
hotkey_handler.change_scene(Scenes::Screen, Some(self.screen_sub_scene));
},
Scenes::Augmented => {
println!("Augment!");
hotkey_handler.change_scene(Scenes::Augmented, None);
}
}

View file

@ -64,9 +64,7 @@ impl StreamState {
StateUpdate::TimerCanRun(new_val) => {self.timer_can_run = new_val;},
StateUpdate::TimerLength(new_val) => {self.timer_length = new_val;},
StateUpdate::TimerText(new_val) => {self.timer_text = new_val;},
StateUpdate::SceneIsAugmented(new_val) => {
self.scene_is_augmented = new_val;
self.change_scene(&Scenes::Augmented)},
StateUpdate::SceneIsAugmented(new_val) => {self.scene_is_augmented = new_val;},
StateUpdate::Scene(_) => {},
StateUpdate::SubScene(_) => {},
StateUpdate::ComputerMediaDoPause => {},
@ -74,12 +72,4 @@ impl StreamState {
StateUpdate::UpdateClient => {},
}
}
pub fn change_scene(&mut self, scene: &Scenes) {
match scene {
Scenes::Augmented => {self.current_scene = *scene;}
Scenes::Camera => {self.current_scene = *scene},
Scenes::Screen => {self.current_scene = *scene},
}
}
}

View file

@ -86,11 +86,11 @@ fn test_json_to_state_update() {
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"update\", \"update\": \"Next_Slide\"}"
).unwrap()), StateUpdate::ChangeSlide(SlideChange::Next));
).unwrap()), StateUpdate::ChangeSlide(SlideChange::NextHotkey));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"update\", \"update\": \"Prev_Slide\"}"
).unwrap()), StateUpdate::ChangeSlide(SlideChange::Previous));
).unwrap()), StateUpdate::ChangeSlide(SlideChange::PreviousHotkey));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"update\", \"update\":\"all\"}"
@ -131,8 +131,8 @@ fn test_state_update_to_json() {
assert_eq!(StateUpdate::SubScene(SubScenes::ScreenWithLowerRight), StateUpdate::json_to_state_update(StateUpdate::SubScene(SubScenes::ScreenWithLowerRight).to_json()));
assert_eq!(StateUpdate::Scene(Scenes::Camera), StateUpdate::json_to_state_update(StateUpdate::Scene(Scenes::Camera).to_json()));
assert_eq!(StateUpdate::Scene(Scenes::Screen), StateUpdate::json_to_state_update(StateUpdate::Scene(Scenes::Screen).to_json()));
assert_eq!(StateUpdate::ChangeSlide(SlideChange::Next), StateUpdate::json_to_state_update(StateUpdate::ChangeSlide(SlideChange::Next).to_json()));
assert_eq!(StateUpdate::ChangeSlide(SlideChange::Previous), StateUpdate::json_to_state_update(StateUpdate::ChangeSlide(SlideChange::Previous).to_json()));
assert_eq!(StateUpdate::ChangeSlide(SlideChange::NextHotkey), StateUpdate::json_to_state_update(StateUpdate::ChangeSlide(SlideChange::NextHotkey).to_json()));
assert_eq!(StateUpdate::ChangeSlide(SlideChange::PreviousHotkey), StateUpdate::json_to_state_update(StateUpdate::ChangeSlide(SlideChange::PreviousHotkey).to_json()));
assert_eq!(StateUpdate::UpdateClient, StateUpdate::json_to_state_update(StateUpdate::UpdateClient.to_json()));
}