-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c29d0cf
commit a11970e
Showing
12 changed files
with
12,381 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Streamer overlay local PORT | ||
pub const OVERLAY_PORT:&str = "47824"; | ||
|
||
// COHDB Auth | ||
pub const COHDB_CLIENT_ID:&str = "kHERjpU_rXcvgvLgwPir0w3bqcgETLOH-p95-PVxN-M"; | ||
pub const COHDB_REDIRECT_URI:&str = "coh3stats://cohdb.com/oauth/authorize"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod parse_log_file; | |
pub mod plugins; | ||
pub mod overlay_server; | ||
pub mod dp_utils; | ||
pub mod config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
use std::fs::File; | ||
use std::panic; | ||
use log::{error, info}; | ||
use std::fs::File; | ||
use std::path::PathBuf; | ||
|
||
use tiny_http::{Server, Response, StatusCode}; | ||
|
||
pub fn run_http_server(streamer_overlay_path: PathBuf) { | ||
|
||
let result = panic::catch_unwind(|| { | ||
use tiny_http::{Response, Server, StatusCode}; | ||
|
||
// Ideally we would allow setting up port in the settings | ||
info!("Starting streamer overlay server on port 47824"); | ||
let server = Server::http("127.0.0.1:47824").unwrap(); | ||
use crate::config::OVERLAY_PORT; | ||
|
||
for request in server.incoming_requests() { | ||
|
||
let file = match File::open(&streamer_overlay_path) { | ||
Ok(file) => file, | ||
Err(_) => { | ||
let response = Response::new_empty(StatusCode(404)); | ||
let _ = request.respond(response); | ||
continue; | ||
} | ||
}; | ||
|
||
let response = Response::from_file(file); | ||
let _ = request.respond(response); | ||
} | ||
|
||
}); | ||
pub fn run_http_server(streamer_overlay_path: PathBuf) { | ||
// Ideally we would allow setting up port in the settings | ||
info!("Starting streamer overlay server on port {}", OVERLAY_PORT); | ||
|
||
if let Err(err) = result { | ||
let server = match Server::http(format!("127.0.0.1:{}", OVERLAY_PORT)) { | ||
Ok(server) => server, | ||
Err(err) => { | ||
error!("Couldn't start the streamer overlay server: {:?}", err); | ||
} | ||
|
||
return; | ||
} | ||
}; | ||
|
||
for request in server.incoming_requests() { | ||
let file = match File::open(&streamer_overlay_path) { | ||
Ok(file) => file, | ||
Err(_) => { | ||
let response = Response::new_empty(StatusCode(404)); | ||
let _ = request.respond(response); | ||
continue; | ||
} | ||
}; | ||
|
||
let response = Response::from_file(file); | ||
let _ = request.respond(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::parse_log_file::{parse_log_file_reverse, GameState}; | ||
|
||
|
||
// TODO: Add more assertions and tests for parsing the log files | ||
|
||
#[test] | ||
fn test_parse_log_file_reverse_file_1() { | ||
// println!("{}", file!()); | ||
let result = parse_log_file_reverse("./test_assets/warnings-1.log".to_string()); | ||
assert_eq!(result.game_state, GameState::Closed); | ||
// can't compare for some reason | ||
// assert_eq!(result.game_type, GameType::Custom); | ||
|
||
assert_eq!(result.duration, 2217); | ||
assert_eq!(result.map, "winter_line_8p_mkii"); | ||
assert_eq!(result.win_condition, "VictoryPoint"); | ||
|
||
// assert some results | ||
// assert_eq!(result.len(), 3); | ||
// print!("{:#?}", result); | ||
} | ||
|
||
#[test] | ||
fn test_parse_log_file_reverse_file_2() { | ||
println!("{}", file!()); | ||
let result = parse_log_file_reverse("./test_assets/warnings-2.log".to_string()); | ||
assert_eq!(result.game_state, GameState::Closed); | ||
|
||
// TODO: add more assertions | ||
|
||
// print!("{:#?}", result); | ||
} | ||
|
||
#[test] | ||
fn test_parse_log_file_reverse_file_3() { | ||
println!("{}", file!()); | ||
let result = parse_log_file_reverse("./test_assets/warnings-3.log".to_string()); | ||
assert_eq!(result.game_state, GameState::Closed); | ||
|
||
assert_eq!(result.map, "desert_village_2p_mkiii"); | ||
// TODO: add more assertions | ||
|
||
|
||
// print!("{:#?}", result); | ||
} |
Oops, something went wrong.